Skip to content

wangqmshf/zaiwen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

在问(zaiwen) API

在问 https://www.zaiwen.top/ API。在问api python client,类似openai client,集成langchain,方便大家学习课程,开发应用。

优势

  1. 不需要代理
  2. 不需要api key
  3. 兼容修改后的接口

设计

sequenceDiagram
    participant 用户
    participant 在问
    participant OpenAI
   用户->>+在问: 发送请求
   在问->>+在问: 添加key,修改请求
   在问->>+OpenAI: 发送请求
   OpenAI->>+在问: 返回响应
   在问->>+在问: 修改响应
   在问->>+用户: 返回响应
Loading

request使用方式

url从浏览器查看

import requests

# 在问url and api
url = "https://www.13042332817.top"

# url = "https://www.gaosijiaoyu.cn"
resource = "/message"
input_message = {"message": [{"role": "user", "content": "你好"}], "mode": "v3.5", "key": None}
response = requests.post(url + resource, json=input_message)
text = response.text
print(text)

api使用方式

from zaiwen.get_completion import get_completion
prompt = f"""
你好
"""
response = get_completion(prompt, url="https://www.13042332817.top")
print(response)

langchain使用方式

需要安装langchain

$ pip install langchain
from zaiwen.zaiwen_llm import ZaiWenLLM

llm = ZaiWenLLM(url="https://www.13042332817.top")
print(llm('你好'))
print(llm)

安装

$ pip install zaiwen

todo

1. 流式传输
2. 更多API例子,chat 模式
3. langchain 集成例子
4. 实现转发服务,兼容现有openai应用,只修改base url即可
   4.1 用户=>转发服务=>在问
   4.2 用户=>转发服务=>openai

License

Apache

Releases

No releases published

Packages

No packages published

Languages