ursa-ai 0.7.0rc2__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ursa-ai might be problematic. Click here for more details.
- ursa/agents/__init__.py +13 -2
- ursa/agents/acquisition_agents.py +812 -0
- ursa/agents/arxiv_agent.py +1 -1
- ursa/agents/base.py +352 -91
- ursa/agents/chat_agent.py +58 -0
- ursa/agents/execution_agent.py +506 -260
- ursa/agents/lammps_agent.py +81 -31
- ursa/agents/planning_agent.py +27 -2
- ursa/agents/websearch_agent.py +2 -2
- ursa/cli/__init__.py +5 -1
- ursa/cli/hitl.py +46 -34
- ursa/observability/pricing.json +85 -0
- ursa/observability/pricing.py +20 -18
- ursa/util/parse.py +316 -0
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/METADATA +5 -1
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/RECORD +20 -17
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/WHEEL +0 -0
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/entry_points.txt +0 -0
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/licenses/LICENSE +0 -0
- {ursa_ai-0.7.0rc2.dist-info → ursa_ai-0.7.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from typing import Annotated, Any, Mapping
|
|
2
|
+
|
|
3
|
+
from langchain_core.language_models import BaseChatModel
|
|
4
|
+
from langchain_openai import ChatOpenAI
|
|
5
|
+
from langgraph.graph import StateGraph
|
|
6
|
+
from langgraph.graph.message import add_messages
|
|
7
|
+
from typing_extensions import TypedDict
|
|
8
|
+
|
|
9
|
+
from .base import BaseAgent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ChatState(TypedDict):
|
|
13
|
+
messages: Annotated[list, add_messages]
|
|
14
|
+
thread_id: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ChatAgent(BaseAgent):
|
|
18
|
+
def __init__(
|
|
19
|
+
self, llm: str | BaseChatModel = "openai/gpt-4o-mini", **kwargs
|
|
20
|
+
):
|
|
21
|
+
super().__init__(llm, **kwargs)
|
|
22
|
+
self._build_graph()
|
|
23
|
+
|
|
24
|
+
def _response_node(self, state: ChatState) -> ChatState:
|
|
25
|
+
res = self.llm.invoke(
|
|
26
|
+
state["messages"], {"configurable": {"thread_id": self.thread_id}}
|
|
27
|
+
)
|
|
28
|
+
return {"messages": [res]}
|
|
29
|
+
|
|
30
|
+
def _build_graph(self):
|
|
31
|
+
graph = StateGraph(ChatState)
|
|
32
|
+
self.add_node(graph, self._response_node)
|
|
33
|
+
graph.set_entry_point("_response_node")
|
|
34
|
+
graph.set_finish_point("_response_node")
|
|
35
|
+
self._action = graph.compile(checkpointer=self.checkpointer)
|
|
36
|
+
|
|
37
|
+
def _invoke(
|
|
38
|
+
self, inputs: Mapping[str, Any], recursion_limit: int = 1000, **_
|
|
39
|
+
):
|
|
40
|
+
config = self.build_config(
|
|
41
|
+
recursion_limit=recursion_limit, tags=["graph"]
|
|
42
|
+
)
|
|
43
|
+
return self._action.invoke(inputs, config)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main():
|
|
47
|
+
model = ChatOpenAI(
|
|
48
|
+
model="gpt-4o", max_tokens=10000, timeout=None, max_retries=2
|
|
49
|
+
)
|
|
50
|
+
websearcher = ChatAgent(llm=model)
|
|
51
|
+
problem_string = "What is your name?"
|
|
52
|
+
print("Prompt: ", problem_string)
|
|
53
|
+
result = websearcher.invoke(problem_string)
|
|
54
|
+
return result["messages"][-1].content
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
print("Response: ", main())
|