feat(model): Passing stop parameter to proxyllm (#2077)

This commit is contained in:
Fangyin Cheng
2024-10-18 14:02:53 +08:00
committed by GitHub
parent cf192a5fb7
commit 53ba6259d2
13 changed files with 31 additions and 4 deletions

View File

@@ -39,6 +39,7 @@ async def chatgpt_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
async for r in client.generate_stream(request):
yield r
@@ -188,6 +189,8 @@ class OpenAILLMClient(ProxyLLMClient):
payload["temperature"] = request.temperature
if request.max_new_tokens:
payload["max_tokens"] = request.max_new_tokens
if request.stop:
payload["stop"] = request.stop
return payload
async def generate(

View File

@@ -27,6 +27,7 @@ async def deepseek_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
async for r in client.generate_stream(request):
yield r

View File

@@ -46,6 +46,7 @@ def gemini_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
for r in client.sync_generate_stream(request):
yield r

View File

@@ -26,6 +26,7 @@ async def moonshot_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
async for r in client.generate_stream(request):
yield r

View File

@@ -47,6 +47,7 @@ def spark_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
for r in client.sync_generate_stream(request):
yield r

View File

@@ -21,6 +21,7 @@ def tongyi_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
for r in client.sync_generate_stream(request):
yield r
@@ -96,6 +97,7 @@ class TongyiLLMClient(ProxyLLMClient):
top_p=0.8,
stream=True,
result_format="message",
stop=request.stop,
)
for r in res:
if r:

View File

@@ -26,6 +26,7 @@ async def yi_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
async for r in client.generate_stream(request):
yield r

View File

@@ -28,6 +28,7 @@ def zhipu_generate_stream(
temperature=params.get("temperature"),
context=context,
max_new_tokens=params.get("max_new_tokens"),
stop=params.get("stop"),
)
for r in client.sync_generate_stream(request):
yield r