mirror of
https://github.com/katanemo/plano.git
synced 2026-07-02 15:51:02 +02:00
Integrate Arch-Function-Chat (#449)
This commit is contained in:
parent
f31aa59fac
commit
7d4b261a68
26 changed files with 558 additions and 603 deletions
4
demos/shared/chatbot_ui/.vscode/launch.json
vendored
4
demos/shared/chatbot_ui/.vscode/launch.json
vendored
|
|
@ -15,7 +15,7 @@
|
|||
"LLM": "1",
|
||||
"CHAT_COMPLETION_ENDPOINT": "http://localhost:10000/v1",
|
||||
"STREAMING": "True",
|
||||
"ARCH_CONFIG": "../../weather_forecast/arch_config.yaml"
|
||||
"ARCH_CONFIG": "../../samples_python/weather_forecast/arch_config.yaml"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
"LLM": "1",
|
||||
"CHAT_COMPLETION_ENDPOINT": "http://localhost:12000/v1",
|
||||
"STREAMING": "True",
|
||||
"ARCH_CONFIG": "../../llm_routing/arch_config.yaml"
|
||||
"ARCH_CONFIG": "../../samples_python/weather_forecast/arch_config.yaml"
|
||||
}
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -120,8 +120,11 @@ def process_stream_chunk(chunk, history):
|
|||
|
||||
if delta.content:
|
||||
# append content to the last history item
|
||||
history[-1]["content"] = history[-1].get("content", "") + delta.content
|
||||
if history[-1]["model"] != "Arch-Function-Chat":
|
||||
history[-1]["content"] = history[-1].get("content", "") + delta.content
|
||||
# yield content if it is from assistant
|
||||
if history[-1]["model"] == "Arch-Function":
|
||||
return None
|
||||
if history[-1]["role"] == "assistant":
|
||||
return delta.content
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,22 @@ def chat(
|
|||
|
||||
yield "", conversation, history, debug_output, model_selector
|
||||
|
||||
# update assistant response to have correct format
|
||||
# arch-fc 1.1 expects following format:
|
||||
# {
|
||||
# "response": "<assistant response>",
|
||||
# }
|
||||
# and this entire block needs to be encoded in ```json\n{json_encoded_content}\n```
|
||||
|
||||
if not history[-1]["model"].startswith("Arch"):
|
||||
assistant_response = {
|
||||
"response": history[-1]["content"],
|
||||
}
|
||||
history[-1]["content"] = "```json\n{}\n```".format(
|
||||
json.dumps(assistant_response)
|
||||
)
|
||||
log.info("history: {}".format(json.dumps(history)))
|
||||
|
||||
|
||||
def main():
|
||||
with gr.Blocks(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue