Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置模型时,可以配置在别的服务器部署的chatglm6b吗 #4012

Open
carllisicau opened this issue May 14, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@carllisicau
Copy link

大佬们 请问下
目前看到文档中,可以配置本地大模型和在线大模型api
但是本地大模型似乎要在一台机器上
langchain chatchat 可以配置部署在另外一台机器上的大模型chatglm6b吗

@carllisicau carllisicau added the bug Something isn't working label May 14, 2024
Copy link

dosubot bot commented May 14, 2024

Yes, you can configure Langchain Chatchat to use a ChatGLM6B model deployed on a different server. Here's how to do it:

  1. Update model_config.py: Add a new entry for your remote model with details like api_base_url and api_key. For example:
ONLINE_LLM_MODEL = {
    "chatglm3-6b-remote": {
        "api_base_url": "https://your.remote.server/api",
        "api_key": "your_api_key_here",
        "provider": "YourProviderWorker",
    },
}
  1. Modify get_ChatOpenAI function: Adjust this function to make HTTP requests to your remote model's API. Use libraries like httpx for asynchronous requests. Here's a basic structure:
import httpx

async def get_ChatOpenAI(model_name: str, temperature: float, max_tokens: Optional[int], callbacks: list):
    api_endpoint = "http://localhost:5000/generate"
    data = {
        "model_name": model_name,
        "temperature": temperature,
        "max_tokens": max_tokens,
    }
    async with httpx.AsyncClient() as client:
        response = await client.post(api_endpoint, json=data)
        generated_text = response.json().get("text", "")
        return generated_text
  1. Configure the application to use the remote model: Ensure your application is set up to use the new remote model identifier you've added.

Remember, network latency and bandwidth are crucial factors to consider for maintaining responsive interactions with the remote model.

For more detailed examples and discussions on similar setups, you might find these threads helpful:

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant