freechat-sdk 2.6.0
FreeChat OpenAPI Definition
Keywords: OpenAPI, OpenAPI-Generator, FreeChat OpenAPI Definition

    # FreeChat: Create Friends for Yourself with AI  English | [中文版](https://github.com/freechat-fun/freechat/blob/main/README.zh-CN.md)  ## Introduction Welcome! FreeChat aims to build a cloud-native, robust, and quickly commercializable enterprise-level AI virtual character platform.  It also serves as a prompt engineering platform.  It is recommended to run [Ollama](https://ollama.com/) + FreeChat locally to test your models. See the instructions below for [running locally](#running-locally)  ## Features - Primarily uses Java and emphasizes **security, robustness, scalability, traceability, and maintainability**. - Boasts **account systems and permission management**, supporting OAuth2 authentication. Introduces the \&quot;organization\&quot; concept and related permission constraint functions. - Extensively employs distributed technologies and caching to support **high concurrency** access. - Provides flexible character customization options, supports direct intervention in prompts, and supports **configuring multiple backends for each character**. - **Offers a comprehensive range of Open APIs**, with [more than 180 methods](https://freechat.fun/w/docs) and provides java/python/typescript SDKs. These methods enable easy construction of systems for end-users. - Supports setting **RAG** (Retrieval Augmented Generation) for characters. - Supports **long-term memory, preset memory** for characters. - Supports characters evoking **proactive chat**. - Supports characters replies with **mixed text and image information**. - Supports setting **quota limits** for characters. - Supports characters **importing and exporting**. - Supports **character-to-character chats**. - Supports **character voices**. - Supports individual **debugging and sharing prompts**.  ## Snapshots ### On PC #### Home Page ![Home Page Snapshot](https://freechat.fun/img/snapshot_w1.jpg) #### Development View ![Development View Snapshot](https://freechat.fun/img/snapshot_w2.jpg) #### Chat View ![Chat View Snapshot](https://freechat.fun/img/snapshot_w3.jpg)  ### On Mobile ![Chat Snapshot 1](https://freechat.fun/img/snapshot_m1.jpg) ![Chat Snapshot 2](https://freechat.fun/img/snapshot_m2.jpg)&lt;br /&gt; ![Chat Snapshot 3](https://freechat.fun/img/snapshot_m3.jpg) ![Chat Snapshot 4](https://freechat.fun/img/snapshot_m4.jpg)  ## Character Design &#x60;&#x60;&#x60;mermaid flowchart TD     A(Character) --&gt; B(Profile)     A --&gt; C(Knowledge/RAG)     A --&gt; D(Album)     A --&gt; E(Backend-1)     A --&gt; F(Backend-n...)     E --&gt; G(Message Window)     E --&gt; H(Long Term Memory Settings)     E --&gt; I(Quota Limit)     E --&gt; J(Chat/Greeting Prompt Tasks)     E --&gt; P(Album/TTS Tools)     E --&gt; L(Moderation Settings)     J --&gt; M(Model &amp; Parameters)     J --&gt; N(API Keys)     J --&gt; O(Prompt Reference)     O --&gt; R(Template)     O --&gt; S(Variables)     O --&gt; T(Version)     O --&gt; U(...)     style L stroke-dasharray: 5, 5 &#x60;&#x60;&#x60;  After setting up an unified persona and knowledge for a character, different backends can be configured. For example, different model may be adopted for different users based on cost considerations.  ## How to Play ### Online Website You can visit [freechat.fun](https://freechat.fun) to experience FreeChat. Share your designed AI character!  ### Running in a Kubernetes Cluster FreeChat is dedicated to the principles of cloud-native design. If you have a Kubernetes cluster, you can deploy FreeChat to your environment by following these steps:  1. Put the Kubernetes configuration file in the &#x60;configs/helm/&#x60; directory, named &#x60;kube-private.conf&#x60;. 2. Place the Helm configuration file in the same directory, named &#x60;values-private.yaml&#x60;. Make sure to reference the default &#x60;values.yaml&#x60; and customize the variables as needed. 3. Switch to the &#x60;scripts/&#x60; directory. 4. If needed, run &#x60;install-in.sh&#x60; to deploy &#x60;ingress-nginx&#x60; on the Kubernetes cluster. 5. If needed, run &#x60;install-cm.sh&#x60; to deploy &#x60;cert-manager&#x60; on the Kubernetes cluster, which automatically issues certificates for domains specified in &#x60;ingress.hosts&#x60;. 6. Run &#x60;install.sh&#x60; script to install FreeChat and its dependencies. 7. FreeChat aims to provide Open API services. If you like the interactive experience of [freechat.fun](https://freechat.fun), run &#x60;install-web.sh&#x60; to deploy the front-end application. 8. Run &#x60;restart.sh&#x60; to restart the service. 9. If you modified any Helm configuration files, use &#x60;upgrade.sh&#x60; to update the corresponding Kubernetes resources. 10. To remove specific resources, run the &#x60;uninstall*.sh&#x60; script corresponding to the resource you want to uninstall.  As a cloud-native application, the services FreeChat relies on are obtained and deployed to your cluster through the helm repository.  If you prefer cloud services with SLA (Service Level Agreement) guarantees, simply make the relevant settings in &#x60;configs/helm/values-private.yaml&#x60;: &#x60;&#x60;&#x60;yaml mysql:   enabled: false   url: &lt;your mysql url&gt;   auth:     rootPassword: &lt;your mysql root password&gt;     username: &lt;your mysql username&gt;     password: &lt;your mysql password for the username&gt;  redis:   enabled: false   url: &lt;your redis url&gt;   auth:     password: &lt;your redis password&gt;   milvus:   enabled: false   url: &lt;your milvus url&gt;   milvus:     auth:       token: &lt;your milvus api-key&gt; &#x60;&#x60;&#x60;  With this, FreeChat will not automatically install these services, but rather use the configuration information to connect directly.  If your Kubernetes cluster does not have a standalone monitoring system, you can enable the following switch. This will install Prometheus and Grafana services in the same namespace, dedicated to monitoring the status of the services under the FreeChat application: &#x60;&#x60;&#x60;yaml prometheus:   enabled: true grafana:   enabled: true &#x60;&#x60;&#x60;  ### Running Locally You can also run FreeChat locally. Currently supported on MacOS and Linux (although only tested on MacOS). You need to install the Docker toolset and have a network that can access [Docker Hub](https://hub.docker.com/).  Once ready, enter the &#x60;scripts/&#x60; directory and run &#x60;local-run.sh&#x60;, which will download and run the necessary docker containers. After a successful startup, you can access &#x60;http://localhost&#x60; via a browser to see the locally running freechat.fun. The built-in administrator username and password are \&quot;admin:freechat\&quot;. Use &#x60;local-run.sh --help&#x60; to view the supported options of the script. Good luck!  ### Running in an IDE To run FreeChat in an IDE, you need to start all dependent services first but do not need to run the container for the FreeChat application itself. You can execute the &#x60;scripts/local-deps.sh&#x60; script to start services like &#x60;MySQL&#x60;, &#x60;Redis&#x60;, &#x60;Milvus&#x60;, etc., locally. Once done, open and debug &#x60;freechat-start/src/main/java/fun/freechat/Application.java&#x60;。Make sure you have set the following startup VM options: &#x60;&#x60;&#x60;shell -Dspring.config.location&#x3D;classpath:/application.yml \ -DAPP_HOME&#x3D;local-data/freechat \ -Dspring.profiles.active&#x3D;local &#x60;&#x60;&#x60;  ### Use SDK #### Java - **Dependency** &#x60;&#x60;&#x60;xml &lt;dependency&gt;   &lt;groupId&gt;fun.freechat&lt;/groupId&gt;   &lt;artifactId&gt;freechat-sdk&lt;/artifactId&gt;   &lt;version&gt;${freechat-sdk.version}&lt;/version&gt; &lt;/dependency&gt; &#x60;&#x60;&#x60;  - **Example** &#x60;&#x60;&#x60;java import fun.freechat.client.ApiClient; import fun.freechat.client.ApiException; import fun.freechat.client.Configuration; import fun.freechat.client.api.AccountApi; import fun.freechat.client.auth.ApiKeyAuth; import fun.freechat.client.model.UserDetailsDTO;  public class AccountClientExample {     public static void main(String[] args) {         ApiClient defaultClient &#x3D; Configuration.getDefaultApiClient();         defaultClient.setBasePath(\&quot;https://freechat.fun\&quot;);                  // Configure HTTP bearer authorization: bearerAuth         HttpBearerAuth bearerAuth &#x3D; (HttpBearerAuth) defaultClient.getAuthentication(\&quot;bearerAuth\&quot;);         bearerAuth.setBearerToken(\&quot;FREECHAT_TOKEN\&quot;);          AccountApi apiInstance &#x3D; new AccountApi(defaultClient);         try {             UserDetailsDTO result &#x3D; apiInstance.getUserDetails();             System.out.println(result);         } catch (ApiException e) {             e.printStackTrace();         }     } } &#x60;&#x60;&#x60;  #### Python - **Installation** &#x60;&#x60;&#x60;shell pip install freechat-sdk &#x60;&#x60;&#x60;  - **Example** &#x60;&#x60;&#x60;python import freechat_sdk from freechat_sdk.rest import ApiException from pprint import pprint  # Defining the host is optional and defaults to https://freechat.fun # See configuration.py for a list of all supported configuration parameters. configuration &#x3D; freechat_sdk.Configuration(     host &#x3D; \&quot;https://freechat.fun\&quot; )  # Configure Bearer authorization: bearerAuth configuration &#x3D; freechat_sdk.Configuration(     access_token &#x3D; os.environ[\&quot;FREECHAT_TOKEN\&quot;] )  # Enter a context with an instance of the API client with freechat_sdk.ApiClient(configuration) as api_client:     # Create an instance of the API class     api_instance &#x3D; freechat_sdk.AccountApi(api_client)      try:         details &#x3D; api_instance.get_user_details()         pprint(details)     except ApiException as e:         print(\&quot;Exception when calling AccountClient-&gt;get_user_details: %s\n\&quot; % e) &#x60;&#x60;&#x60;  #### TypeScript - **Installation** &#x60;&#x60;&#x60;shell npm install freechat-sdk --save &#x60;&#x60;&#x60;  - **Example**  Refer to [FreeChatApiContext.tsx](https://github.com/freechat-fun/freechat/blob/main/freechat-web/src/contexts/FreeChatApiProvider.tsx)  ## System Dependencies | | Projects | ---- | ---- | Application Framework | [Spring Boot](https://spring.io/projects/spring-boot/) | LLM Framework | [LangChain4j](https://docs.langchain4j.dev/) | Model Providers | [Ollama](https://ollama.com/), [OpenAI](https://platform.openai.com/), [Azure OpenAI](https://oai.azure.com/), [DashScope(Alibaba)](https://dashscope.aliyun.com/) | Database Systems | [MySQL](https://www.mysql.com/), [Redis](https://redis.io/), [Milvus](https://milvus.io/) | Monitoring &amp; Alerting | [Kube State Metrics](https://kubernetes.io/docs/concepts/cluster-administration/kube-state-metrics/), [Prometheus](https://prometheus.io/), [Promtail](https://grafana.com/docs/loki/latest/send-data/promtail/), [Loki](https://grafana.com/oss/loki/), [Grafana](https://grafana.com/) | OpenAPI Tools | [Springdoc-openapi](https://springdoc.org/), [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator), [OpenAPI Explorer](https://github.com/Authress-Engineering/openapi-explorer)  ## Collaboration ### Application Integration The FreeChat system is entirely oriented towards Open APIs. The site [freechat.fun](https://freechat.fun) is developed using its TypeScript SDK and hardly depends on private interfaces. You can use these online interfaces to develop your own applications or sites, making them fit your preferences. Currently, the online FreeChat service is completely free and there are no current plans for charging.  ### Model Integration FreeChat aims to explore AI virtual character technology with anthropomorphic characteristics. If you are researching this area and hope FreeChat supports your model, please contact us. We look forward to AI technology helping people create their own \&quot;soul mates\&quot; in the future.