Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -3,6 +3,8 @@ import os
|
|
| 3 |
import time
|
| 4 |
import datetime
|
| 5 |
import pandas as pd
|
|
|
|
|
|
|
| 6 |
import langsmith as ls
|
| 7 |
from pathlib import Path
|
| 8 |
import chainlit as cl
|
|
@@ -11,6 +13,7 @@ from mistralai import Mistral, UserMessage, SystemMessage
|
|
| 11 |
from offres_emploi import Api
|
| 12 |
from offres_emploi.utils import dt_to_str_iso
|
| 13 |
os.environ["GITHUB_TOKEN"] = os.environ["GITHUB_TOKEN"]
|
|
|
|
| 14 |
|
| 15 |
@cl.step(type="tool", show_input=True)
|
| 16 |
@ls.traceable(run_type="tool", name="Retrieve Context : chargement des données Gustaviz")
|
|
@@ -134,6 +137,7 @@ def Generation_completion(client, data, question):
|
|
| 134 |
return msg
|
| 135 |
|
| 136 |
@cl.step(type="tool", show_input=True)
|
|
|
|
| 137 |
async def Affichage_reponse(response):
|
| 138 |
msg = cl.Message(author="COPILOT",content="")
|
| 139 |
|
|
@@ -450,7 +454,7 @@ async def main(message: cl.Message):
|
|
| 450 |
|
| 451 |
app_inputs = {"input": message.content}
|
| 452 |
with ls.trace("Réponse de l'assistant sur les données MIS", "chain", project_name=cl.user_session.get("chat_profile"), inputs=app_inputs) as rt:
|
| 453 |
-
msg = await Affichage_reponse(response)
|
| 454 |
rt.end(outputs={"output": msg})
|
| 455 |
|
| 456 |
answer = msg.content
|
|
|
|
| 3 |
import time
|
| 4 |
import datetime
|
| 5 |
import pandas as pd
|
| 6 |
+
from langsmith import traceable
|
| 7 |
+
import uuid
|
| 8 |
import langsmith as ls
|
| 9 |
from pathlib import Path
|
| 10 |
import chainlit as cl
|
|
|
|
| 13 |
from offres_emploi import Api
|
| 14 |
from offres_emploi.utils import dt_to_str_iso
|
| 15 |
os.environ["GITHUB_TOKEN"] = os.environ["GITHUB_TOKEN"]
|
| 16 |
+
session_id = str(uuid.uuid4())
|
| 17 |
|
| 18 |
@cl.step(type="tool", show_input=True)
|
| 19 |
@ls.traceable(run_type="tool", name="Retrieve Context : chargement des données Gustaviz")
|
|
|
|
| 137 |
return msg
|
| 138 |
|
| 139 |
@cl.step(type="tool", show_input=True)
|
| 140 |
+
@traceable(run_type="chain", name="Mistral Assistant des datas Gustaviz",)
|
| 141 |
async def Affichage_reponse(response):
|
| 142 |
msg = cl.Message(author="COPILOT",content="")
|
| 143 |
|
|
|
|
| 454 |
|
| 455 |
app_inputs = {"input": message.content}
|
| 456 |
with ls.trace("Réponse de l'assistant sur les données MIS", "chain", project_name=cl.user_session.get("chat_profile"), inputs=app_inputs) as rt:
|
| 457 |
+
msg = await Affichage_reponse(response, langsmith_extra={"metadata": {"session_id": session_id}})
|
| 458 |
rt.end(outputs={"output": msg})
|
| 459 |
|
| 460 |
answer = msg.content
|