|
- # coding=utf-8
- from llms.llm import Llm
- import requests
- import json
-
-
- class Liandongllm(Llm):
- def __init__(self, **param):
- self.api_url = param['api_url']
-
- def link(self, question):
- headers = {
- 'Content-Type': 'json',
- 'Content-Length': '<calculated when request is sent>'
- }
- data = {
- "category": "bj_unicom",
- "messages": [
- {
- "role": "user",
- "content": question
- }
- ]
- }
- result = requests.post(self.api_url,
- headers=headers,
- data=json.dumps(data))
- result_json = json.loads(result.text)
- return result_json['data'][0]['text'], 0
|