Spaces:
Runtime error
Runtime error
Update chain_app.py
Browse files- chain_app.py +64 -0
chain_app.py
CHANGED
|
@@ -1002,6 +1002,34 @@ async def chat_profile():
|
|
| 1002 |
|
| 1003 |
]
|
| 1004 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1005 |
# # cl.ChatProfile(
|
| 1006 |
# # name="Toka-353M",
|
| 1007 |
# # markdown_description="PartAI Open Source model Toka with 353M parameters",
|
|
@@ -1927,6 +1955,26 @@ async def on_chat_start():
|
|
| 1927 |
),
|
| 1928 |
]
|
| 1929 |
).send()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1930 |
# await cl.Message(
|
| 1931 |
# content="Im Mistral nemo 12B .i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
|
| 1932 |
# ).send()
|
|
@@ -2476,6 +2524,22 @@ async def main(message: cl.Message):
|
|
| 2476 |
|
| 2477 |
).send()
|
| 2478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2479 |
# elif chat_profile == 'Toka-353M':
|
| 2480 |
# output = query({
|
| 2481 |
# "inputs": message.content,
|
|
|
|
| 1002 |
|
| 1003 |
]
|
| 1004 |
),
|
| 1005 |
+
cl.ChatProfile(
|
| 1006 |
+
name='mistral-7B-v2',
|
| 1007 |
+
markdown_description = 'mistral open source LLM with 7B parameters',
|
| 1008 |
+
starters=[
|
| 1009 |
+
cl.Starter(
|
| 1010 |
+
label="Morning routine ideation",
|
| 1011 |
+
message="Can you help me create a personalized morning routine that would help increase my productivity throughout the day? Start by asking me about my current habits and what activities energize me in the morning.",
|
| 1012 |
+
icon="https://chainlit-rag-copilot-r2xd.onrender.com/public/idea.svg",
|
| 1013 |
+
),
|
| 1014 |
+
|
| 1015 |
+
cl.Starter(
|
| 1016 |
+
label="Explain superconductors",
|
| 1017 |
+
message="Explain superconductors like I'm five years old.",
|
| 1018 |
+
icon="https://chainlit-rag-copilot-r2xd.onrender.com/public/learn.svg",
|
| 1019 |
+
),
|
| 1020 |
+
cl.Starter(
|
| 1021 |
+
label="Python script for daily email reports",
|
| 1022 |
+
message="Write a script to automate sending daily email reports in Python, and walk me through how I would set it up.",
|
| 1023 |
+
icon="https://chainlit-rag-copilot-r2xd.onrender.com/public/terminal.svg",
|
| 1024 |
+
),
|
| 1025 |
+
cl.Starter(
|
| 1026 |
+
label="Text inviting friend to wedding",
|
| 1027 |
+
message="Write a text asking a friend to be my plus-one at a wedding next month. I want to keep it super short and casual, and offer an out.",
|
| 1028 |
+
icon="https://chainlit-rag-copilot-r2xd.onrender.com/public/write.svg",
|
| 1029 |
+
)
|
| 1030 |
+
|
| 1031 |
+
]
|
| 1032 |
+
),
|
| 1033 |
# # cl.ChatProfile(
|
| 1034 |
# # name="Toka-353M",
|
| 1035 |
# # markdown_description="PartAI Open Source model Toka with 353M parameters",
|
|
|
|
| 1955 |
),
|
| 1956 |
]
|
| 1957 |
).send()
|
| 1958 |
+
|
| 1959 |
+
if chat_profile == 'mistral-7B-v2':
|
| 1960 |
+
await cl.ChatSettings(
|
| 1961 |
+
[
|
| 1962 |
+
Select(
|
| 1963 |
+
id="Mistral-Model",
|
| 1964 |
+
label="Mistral - Model",
|
| 1965 |
+
values=["mistral-7B-v2"],
|
| 1966 |
+
initial_index=0,
|
| 1967 |
+
),
|
| 1968 |
+
Slider(
|
| 1969 |
+
id="Temperature",
|
| 1970 |
+
label="Model Temperature",
|
| 1971 |
+
initial=0.7,
|
| 1972 |
+
min=0,
|
| 1973 |
+
max=1,
|
| 1974 |
+
step=0.1,
|
| 1975 |
+
),
|
| 1976 |
+
]
|
| 1977 |
+
).send()
|
| 1978 |
# await cl.Message(
|
| 1979 |
# content="Im Mistral nemo 12B .i was configured by Artin Daneshvar and Sadra Noadoust, 2 iranian students to help you, how can i assist you today ? "
|
| 1980 |
# ).send()
|
|
|
|
| 2524 |
|
| 2525 |
).send()
|
| 2526 |
|
| 2527 |
+
elif chat_profile == 'mistral-7B-v2':
|
| 2528 |
+
client = InferenceClient(
|
| 2529 |
+
"mistralai/Mistral-7B-Instruct-v0.2",
|
| 2530 |
+
token=f"{hf_token_llama_3_1}",
|
| 2531 |
+
)
|
| 2532 |
+
complete_message = ""
|
| 2533 |
+
for message in client.chat_completion(
|
| 2534 |
+
messages=[{"role": "user", "content": message.content}],
|
| 2535 |
+
max_tokens=500,
|
| 2536 |
+
stream=False,
|
| 2537 |
+
):
|
| 2538 |
+
complete_message += message.choices[0].delta.content
|
| 2539 |
+
await cl.Message(content=complete_message).send()
|
| 2540 |
+
|
| 2541 |
+
|
| 2542 |
+
|
| 2543 |
# elif chat_profile == 'Toka-353M':
|
| 2544 |
# output = query({
|
| 2545 |
# "inputs": message.content,
|