知识库retrival使用glm-4-plus,并且设置max_tokens=4095
This commit is contained in:
parent
2179d4e71e
commit
d9caf9acce
|
|
@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ZhipuKbService:
|
class ZhipuKbService:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.model_name = "glm-4"
|
self.model_name = "glm-4-plus"
|
||||||
self.app_secret_key = "d54f764a1d67c17d857bd3983b772016.GRjowY0fyiMNurLc"
|
self.app_secret_key = "d54f764a1d67c17d857bd3983b772016.GRjowY0fyiMNurLc"
|
||||||
logger.info("ZhipuKbService initialized with model: %s", self.model_name)
|
logger.info("ZhipuKbService initialized with model: %s", self.model_name)
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ class ZhipuKbService:
|
||||||
prompt_template = default_prompt
|
prompt_template = default_prompt
|
||||||
try:
|
try:
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4",
|
model=self.model_name,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": message},
|
{"role": "user", "content": message},
|
||||||
],
|
],
|
||||||
|
|
@ -36,8 +36,9 @@ class ZhipuKbService:
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
stream=False,
|
stream=False,
|
||||||
temperature=0.01,
|
max_tokens=4095,
|
||||||
top_p=0.1,
|
temperature=0.01, # default=0.01
|
||||||
|
top_p=0.1, #default=0.1
|
||||||
)
|
)
|
||||||
result = response.choices[0].message.content
|
result = response.choices[0].message.content
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
|
|
@ -59,7 +60,7 @@ class ZhipuKbService:
|
||||||
prompt_template = default_prompt
|
prompt_template = default_prompt
|
||||||
try:
|
try:
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4",
|
model=self.model_name,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=[
|
tools=[
|
||||||
{
|
{
|
||||||
|
|
@ -71,8 +72,9 @@ class ZhipuKbService:
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
stream=True,
|
stream=True,
|
||||||
temperature=0.01,
|
max_tokens=4095,
|
||||||
top_p=0.1,
|
temperature=0.01, # default=0.01
|
||||||
|
top_p=0.1, #default=0.1
|
||||||
)
|
)
|
||||||
for chunk in response:
|
for chunk in response:
|
||||||
yield chunk.choices[0].delta.content
|
yield chunk.choices[0].delta.content
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue