diff --git a/.gitignore b/.gitignore index ff142ad..f35a1af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,33 +1,235 @@ -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -!gradle/wrapper/gradle-wrapper.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -# IntelliJ Files # -.idea/ -*.iml -# Ignore Gradle project-specific cache directory +### Gradle ### .gradle +build/ -# Ignore Gradle build output directory -build +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + + +### Intellij+iml ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij+iml Patch ### +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..0a8642f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Zeppelin ignored files +/ZeppelinRemoteNotebooks/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..f9c0925 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b3d4c01 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..7f6fb97 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jpa-buddy.xml b/.idea/jpa-buddy.xml new file mode 100644 index 0000000..966d5f5 --- /dev/null +++ b/.idea/jpa-buddy.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f5f2744 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8aa2645..5a73c90 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) [year] [fullname] +Copyright (c) 2023 OSSEZ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1b7d37 --- /dev/null +++ b/README.md @@ -0,0 +1,259 @@ +# Rets-Io + +The Rets-Io RETS Client - Java is a library used to access data on RETS compliant servers. + +## Links and related projects + +| Project | URL | NOTE | +|------------------|----------------------------------------------------------------------------|------------------------| +| jrets | [https://github.com/jpfielding/jrets](https://github.com/jpfielding/jrets) | fork from this proejct | +| CART RETS client | [http://cart.sourceforge.net/](http://cart.sourceforge.net/) | Init submit form 2004 | + +# 公众平台 + +我们建议您通过社区论坛来和我们进行沟通,请关注我们公众平台上的账号 + +## 微信公众号 + +![](https://cdn.ossez.com/img/cwikius/cwikius-qr-wechat-search-w400.png) + +## 头条号 + +我们也在头条号上创建了我们的公众号,请扫描下面的 QR 关注我们的头条号。 + +![](https://cdn.ossez.com/img/cwikius/cwikus-qr-toutiao.png) + +## 知乎 + +请关注我们的知乎:https://www.zhihu.com/people/huyuchengus + +# Examples + +Simple example of a search: + +``` +public static void main(String[] args) throws MalformedURLException { + + //Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability) + RetsHttpClient httpClient = new CommonsHttpClient(); + RetsVersion retsVersion = RetsVersion.RETS_1_7_2; + String loginUrl = "http://theurloftheretsserver.com"; + + //Create a RetesSession with RetsHttpClient + RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion); + + String username = "username"; + String password = "password"; + + //Set method as GET or POST + session.setMethod("POST"); + try { + //Login + session.login(username, password); + } catch (RetsException e) { + e.printStackTrace(); + } + + String sQuery = "(Member_num=.ANY.)"; + String sResource = "Property"; + String sClass = "Residential"; + + //Create a SearchRequest + SearchRequest request = new SearchRequest(sResource, sClass, sQuery); + + //Select only available fields + String select ="field1,field2,field3,field4,field5"; + request.setSelect(select); + + //Set request to retrive count if desired + request.setCountFirst(); + + SearchResultImpl response; + try { + //Execute the search + response= (SearchResultImpl) session.search(request); + + //Print out count and columns + int count = response.getCount(); + System.out.println("COUNT: " + count); + System.out.println("COLUMNS: " + StringUtils.join(response.getColumns(), "\t")); + + //Iterate over, print records + for (int row = 0; row < response.getRowCount(); row++){ + System.out.println("ROW"+ row +": " + StringUtils.join(response.getRow(row), "\t")); + } + } catch (RetsException e) { + e.printStackTrace(); + } + finally { + if(session != null) { + try { + session.logout(); + } + catch(RetsException e) { + e.printStackTrace(); + } + } + } +``` + +Simple example making a GetObjectRequest: + +``` + public static void main(String[] args) throws MalformedURLException { + + //Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability) + RetsHttpClient httpClient = new CommonsHttpClient(); + RetsVersion retsVersion = RetsVersion.RETS_1_7_2; + String loginUrl = "http://theurloftheretsserver.com"; + + //Create a RetesSession with RetsHttpClient + RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion); + + String username = "username"; + String password = "password"; + try { + //Login + session.login(username, password); + } catch (RetsException e) { + e.printStackTrace(); + } + + String sResource = "Property"; + String objType = "Photo"; + String seqNum = "*"; // * denotes get all pictures associated with id (from Rets Spec) + List idsList = Arrays.asList("331988","152305","243374"); + try { + //Create a GetObjectRequeset + GetObjectRequest req = new GetObjectRequest(sResource, objType); + + //Add the list of ids to request on (ids can be determined from records) + Iterator idsIter = idsList.iterator(); + while(idsIter.hasNext()) { + req.addObject(idsIter.next(), seqNum); + } + + //Execute the retrieval of objects + Iterator singleObjectResponseIter = session.getObject(req).iterator(); + + //Iterate over each Object + while (singleObjectResponseIter.hasNext()) { + SingleObjectResponse sor = (SingleObjectResponse)singleObjectResponseIter.next(); + + //Retrieve in info and print + String type = sor.getType(); + String contentID = sor.getContentID(); + String objectID = sor.getObjectID(); + String description = sor.getDescription(); + String location = sor.getLocation(); + InputStream is = sor.getInputStream(); + + System.out.print("type:" + type); + System.out.print(" ,contentID:" + contentID); + System.out.print(" ,objectID:" + objectID); + System.out.println(" ,description:" + description); + System.out.println("location:" + location); + + //Download object + try { + String dest = "/path/of/dowload/loaction"; + int size = is.available(); + String filename = dest + contentID +"-" + objectID + ".jpeg"; + OutputStream out = new FileOutputStream(new File(filename)); + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = is.read(bytes)) != -1) { + + out.write(bytes, 0, read); + } + + is.close(); + out.flush(); + out.close(); + + System.out.println("New file with size " + size + " created: " + filename); + } catch (IOException e) { + System.out.println(e.getMessage()); + } + + } + + } catch (RetsException e) { + e.printStackTrace(); + } + finally { + if(session != null) { + try { + session.logout(); + } + catch (RetsException e) { + e.printStackTrace(); + } + } + } + } +``` + +Example of Geting Metadata: + +``` + public static void main(String[] args) throws MalformedURLException { + + //Create a RetsHttpClient (other constructors provide configuration i.e. timeout, gzip capability) + RetsHttpClient httpClient = new CommonsHttpClient(); + RetsVersion retsVersion = RetsVersion.RETS_1_7_2; + String loginUrl = "http://theurloftheretsserver.com"; + + //Create a RetesSession with RetsHttpClient + RetsSession session = new RetsSession(loginUrl, httpClient, retsVersion); + + String username = "username"; + String password = "password"; + + //Set method as GET or POST + session.setMethod("POST"); + try { + //Login + session.login(username, password); + } catch (RetsException e) { + e.printStackTrace(); + } + + try { + MSystem system = session.getMetadata().getSystem(); + System.out.println( + "SYSTEM: " + system.getSystemID() + + " - " + system.getSystemDescription()); + + for(MResource resource: system.getMResources()) { + + System.out.println( + " RESOURCE: " + resource.getResourceID()); + + for(MClass classification: resource.getMClasses()) { + System.out.println( + " CLASS: " + classification.getClassName() + + " - " + classification.getDescription()); + } + } + } + catch (RetsException e) { + e.printStackTrace(); + } + finally { + if(session != null) { + try { + session.logout(); + } + catch(RetsException e) { + e.printStackTrace(); + } + } + } + } +``` + +## License + +[USRealEstate RETS Client is licensed under the MIT License](https://github.com/ossez-com/reoc-mls-client/blob/master/LICENSE) diff --git a/openai-j-api/src/main/java/com/ossez/openai/completion/CompletionRequestBuilder.java b/openai-j-api/src/main/java/com/ossez/openai/completion/CompletionRequestBuilder.java new file mode 100644 index 0000000..3d42a4e --- /dev/null +++ b/openai-j-api/src/main/java/com/ossez/openai/completion/CompletionRequestBuilder.java @@ -0,0 +1,101 @@ +package com.ossez.openai.completion; + +import java.util.List; +import java.util.Map; + +public class CompletionRequestBuilder { + private String model; + private String prompt; + private Integer maxTokens; + private Double temperature; + private Double topP; + private Integer n; + private Boolean stream; + private Integer logprobs; + private Boolean echo; + private List stop; + private Double presencePenalty; + private Double frequencyPenalty; + private Integer bestOf; + private Map logitBias; + private String user; + + public CompletionRequestBuilder setModel(String model) { + this.model = model; + return this; + } + + public CompletionRequestBuilder setPrompt(String prompt) { + this.prompt = prompt; + return this; + } + + public CompletionRequestBuilder setMaxTokens(Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + public CompletionRequestBuilder setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public CompletionRequestBuilder setTopP(Double topP) { + this.topP = topP; + return this; + } + + public CompletionRequestBuilder setN(Integer n) { + this.n = n; + return this; + } + + public CompletionRequestBuilder setStream(Boolean stream) { + this.stream = stream; + return this; + } + + public CompletionRequestBuilder setLogprobs(Integer logprobs) { + this.logprobs = logprobs; + return this; + } + + public CompletionRequestBuilder setEcho(Boolean echo) { + this.echo = echo; + return this; + } + + public CompletionRequestBuilder setStop(List stop) { + this.stop = stop; + return this; + } + + public CompletionRequestBuilder setPresencePenalty(Double presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + public CompletionRequestBuilder setFrequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + public CompletionRequestBuilder setBestOf(Integer bestOf) { + this.bestOf = bestOf; + return this; + } + + public CompletionRequestBuilder setLogitBias(Map logitBias) { + this.logitBias = logitBias; + return this; + } + + public CompletionRequestBuilder setUser(String user) { + this.user = user; + return this; + } + + public CompletionRequest createCompletionRequest() { + return new CompletionRequest(model, prompt, maxTokens, temperature, topP, n, stream, logprobs, echo, stop, presencePenalty, frequencyPenalty, bestOf, logitBias, user); + } +} \ No newline at end of file diff --git a/openai-j-api/src/main/java/com/ossez/openai/edit/EditRequestBuilder.java b/openai-j-api/src/main/java/com/ossez/openai/edit/EditRequestBuilder.java new file mode 100644 index 0000000..424f501 --- /dev/null +++ b/openai-j-api/src/main/java/com/ossez/openai/edit/EditRequestBuilder.java @@ -0,0 +1,46 @@ +package com.ossez.openai.edit; + +import org.checkerframework.checker.nullness.qual.NonNull; + +public class EditRequestBuilder { + private String model; + private String input; + private @NonNull String instruction; + private Integer n; + private Double temperature; + private Double topP; + + public EditRequestBuilder setModel(String model) { + this.model = model; + return this; + } + + public EditRequestBuilder setInput(String input) { + this.input = input; + return this; + } + + public EditRequestBuilder setInstruction(@NonNull String instruction) { + this.instruction = instruction; + return this; + } + + public EditRequestBuilder setN(Integer n) { + this.n = n; + return this; + } + + public EditRequestBuilder setTemperature(Double temperature) { + this.temperature = temperature; + return this; + } + + public EditRequestBuilder setTopP(Double topP) { + this.topP = topP; + return this; + } + + public EditRequest createEditRequest() { + return new EditRequest(model, input, instruction, n, temperature, topP); + } +} \ No newline at end of file diff --git a/openai-j-api/src/main/java/com/ossez/openai/embedding/EmbeddingRequestBuilder.java b/openai-j-api/src/main/java/com/ossez/openai/embedding/EmbeddingRequestBuilder.java new file mode 100644 index 0000000..64e9c9d --- /dev/null +++ b/openai-j-api/src/main/java/com/ossez/openai/embedding/EmbeddingRequestBuilder.java @@ -0,0 +1,30 @@ +package com.ossez.openai.embedding; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.List; + +public class EmbeddingRequestBuilder { + private String model; + private @NonNull List input; + private String user; + + public EmbeddingRequestBuilder setModel(String model) { + this.model = model; + return this; + } + + public EmbeddingRequestBuilder setInput(@NonNull List input) { + this.input = input; + return this; + } + + public EmbeddingRequestBuilder setUser(String user) { + this.user = user; + return this; + } + + public EmbeddingRequest createEmbeddingRequest() { + return new EmbeddingRequest(model, input, user); + } +} \ No newline at end of file