Minimal Viable Product
C'est moche, bancal, et mal foutu, mais ça compile et ça crache un rapport de stage dans un fichier
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
from langgraph.graph import START, END
|
from langgraph.graph import START, END
|
||||||
from langgraph.graph.state import CompiledStateGraph
|
from langgraph.graph.state import CompiledStateGraph
|
||||||
|
|
||||||
from utils.nodes import reponse_question, tool_node, should_continue
|
from utils.nodes import call_to_LLM, should_continue, task_ended, BasicToolNode, tool_node
|
||||||
from utils.state import getState
|
from utils.state import getState
|
||||||
|
from utils.tools import getTools
|
||||||
|
|
||||||
def getGraph()->CompiledStateGraph:
|
def getGraph()->CompiledStateGraph:
|
||||||
"""
|
"""
|
||||||
@@ -14,15 +15,15 @@ def getGraph()->CompiledStateGraph:
|
|||||||
workflow = getState() # State prêt à utiliser
|
workflow = getState() # State prêt à utiliser
|
||||||
|
|
||||||
# Définition des sommets du graphe
|
# Définition des sommets du graphe
|
||||||
workflow.add_node(reponse_question)
|
workflow.add_node(call_to_LLM)
|
||||||
workflow.add_node("tool_node", tool_node) # N'est pas une fonction, mais une classe instanciée, je dois précisier le nom du node
|
workflow.add_node("tool_node", tool_node)# BasicToolNode(tools=getTools())) # N'est pas une fonction, mais une classe instanciée, je dois précisier le nom du node
|
||||||
|
|
||||||
# Arrêtes
|
# Arrêtes
|
||||||
workflow.set_entry_point("reponse_question")
|
workflow.set_entry_point("call_to_LLM")
|
||||||
workflow.add_edge("tool_node", "reponse_question")
|
workflow.add_edge("tool_node", "call_to_LLM")
|
||||||
workflow.add_conditional_edges("reponse_question", should_continue, {
|
workflow.add_conditional_edges("call_to_LLM", should_continue, {
|
||||||
"tools":"tool_node",
|
"tools":"tool_node",
|
||||||
END:END
|
"no_tools":END
|
||||||
})
|
})
|
||||||
|
|
||||||
return workflow.compile()
|
return workflow.compile()
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ from agent import getGraph
|
|||||||
mlflow.set_experiment("TEST PROJET") # VOIR AVEC LA COMMANDE "MLFLOW SERVER"
|
mlflow.set_experiment("TEST PROJET") # VOIR AVEC LA COMMANDE "MLFLOW SERVER"
|
||||||
mlflow.langchain.autolog()
|
mlflow.langchain.autolog()
|
||||||
|
|
||||||
out_state = getGraph().invoke({'messages':[HumanMessage("What's the price for bitcoin ?")]})
|
out_state = getGraph().invoke({'messages':[HumanMessage("Observe la base de documents, et génère un rapport de stage à partir de celle-ci. Ecris le dans un fichier markdown.")]})
|
||||||
for message in out_state['messages']:
|
for message in out_state['messages']:
|
||||||
message.pretty_print()
|
message.pretty_print()
|
||||||
@@ -53,6 +53,8 @@ def task_ended(state: MessagesState):
|
|||||||
return END
|
return END
|
||||||
return "continue"
|
return "continue"
|
||||||
|
|
||||||
|
tool_node = ToolNode(tools=getTools())
|
||||||
|
|
||||||
|
|
||||||
class BasicToolNode: # De mon ancien projet, https://github.com/LJ5O/Assistant/blob/main/modules/Brain/src/LLM/graph/nodes/BasicToolNode.py
|
class BasicToolNode: # De mon ancien projet, https://github.com/LJ5O/Assistant/blob/main/modules/Brain/src/LLM/graph/nodes/BasicToolNode.py
|
||||||
"""A node that runs the tools requested in the last AIMessage."""
|
"""A node that runs the tools requested in the last AIMessage."""
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ def write_file(file_path:str, content: str, append:bool=True) -> str:
|
|||||||
return f"Erreur lors de l'écriture: {str(e)}"
|
return f"Erreur lors de l'écriture: {str(e)}"
|
||||||
|
|
||||||
@tool
|
@tool
|
||||||
def editTodo(index:int, state:int, state: Annotated[dict, InjectedState])->bool: # https://stackoverflow.com/a/79525434
|
def editTodo(index:int, todoState:int, state: Annotated[dict, InjectedState])->bool: # https://stackoverflow.com/a/79525434
|
||||||
"""
|
"""
|
||||||
Modifier l'état d'une tâche (TODO)
|
Modifier l'état d'une tâche (TODO)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
index (int): Index de la tâche à modifier, en commançant à 0 pour la première tâche.
|
index (int): Index de la tâche à modifier, en commançant à 0 pour la première tâche.
|
||||||
state (int): Nouvel état. 0 pour "non commencé, 1 pour "en cours", 2 pour "complété"
|
todoState (int): Nouvel état. 0 pour "non commencé, 1 pour "en cours", 2 pour "complété"
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: Réussite de l'opération, ou non.
|
bool: Réussite de l'opération, ou non.
|
||||||
@@ -63,7 +63,7 @@ def editTodo(index:int, state:int, state: Annotated[dict, InjectedState])->bool:
|
|||||||
# Erreur, l'index est trop grand
|
# Erreur, l'index est trop grand
|
||||||
return False
|
return False
|
||||||
|
|
||||||
state["todo"][index].state = state # Modification de l'état de cette tâche
|
state["todo"][index].state = todoState # Modification de l'état de cette tâche
|
||||||
|
|
||||||
# Toutes les tâches complétées ?
|
# Toutes les tâches complétées ?
|
||||||
found = False
|
found = False
|
||||||
@@ -168,9 +168,9 @@ def search_in_files(query:str, state: Annotated[dict, InjectedState])->str:
|
|||||||
Returns:
|
Returns:
|
||||||
str: Échantillons de documents correspondants, concaténés en une seule chaîne de caractères.
|
str: Échantillons de documents correspondants, concaténés en une seule chaîne de caractères.
|
||||||
"""
|
"""
|
||||||
bdd = VectorDatabase() # Récupère l'unique instance de cette BDD, c'est un SIngleton
|
bdd = VectorDatabase.getChroma() # Récupère l'unique instance de cette BDD, c'est un SIngleton
|
||||||
|
|
||||||
retrieved_docs = bdd.getChroma().similarity_search(query, k=5) # 5 documents
|
retrieved_docs = bdd.similarity_search(query, k=5) # 5 documents
|
||||||
|
|
||||||
# Conversion des documents en texte
|
# Conversion des documents en texte
|
||||||
docs_content = "\n".join(
|
docs_content = "\n".join(
|
||||||
|
|||||||
@@ -14,8 +14,9 @@
|
|||||||
- [X] Préparation du `State`
|
- [X] Préparation du `State`
|
||||||
- [X] Développement des outils de l'agent
|
- [X] Développement des outils de l'agent
|
||||||
- [X] Préparation des nœuds
|
- [X] Préparation des nœuds
|
||||||
- [ ] Branchement des nœuds entre-eux
|
- [X] Branchement des nœuds entre-eux, **MVP**
|
||||||
- [ ] Human in the loop
|
- [ ] Human in the loop
|
||||||
|
- [ ] Amélioration du workflow
|
||||||
|
|
||||||
## Amélioration de l'agent
|
## Amélioration de l'agent
|
||||||
- [ ] Cross-encoding sur la sortie du **RAG**
|
- [ ] Cross-encoding sur la sortie du **RAG**
|
||||||
|
|||||||
Reference in New Issue
Block a user