Skip to content

Commit de4c487

Browse files
committed
Add descriptions
1 parent 65a21dd commit de4c487

File tree

5 files changed

+27
-254
lines changed

5 files changed

+27
-254
lines changed

README.md

Lines changed: 2 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUA
4040
-->
4141

4242
<details>
43-
<summary>Setup for `model_name` and `scraper_tool_model_name`</summary>
43+
<summary>Setup for `model_name`</summary>
4444
The `llm` configuration defaults are shown below:
4545

4646
```yaml
4747
model_name: anthropic/claude-3-5-sonnet-20240620
48-
scraper_tool_model_name: accounts/fireworks/models/firefunction-v2
4948
```
5049
5150
Follow the instructions below to get set up, or pick one of the additional options.
@@ -125,192 +124,7 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
125124
"model_name": {
126125
"type": "string",
127126
"default": "anthropic/claude-3-5-sonnet-20240620",
128-
"environment": [
129-
{
130-
"value": "anthropic/claude-1.2",
131-
"variables": "ANTHROPIC_API_KEY"
132-
},
133-
{
134-
"value": "anthropic/claude-2.0",
135-
"variables": "ANTHROPIC_API_KEY"
136-
},
137-
{
138-
"value": "anthropic/claude-2.1",
139-
"variables": "ANTHROPIC_API_KEY"
140-
},
141-
{
142-
"value": "anthropic/claude-3-5-sonnet-20240620",
143-
"variables": "ANTHROPIC_API_KEY"
144-
},
145-
{
146-
"value": "anthropic/claude-3-haiku-20240307",
147-
"variables": "ANTHROPIC_API_KEY"
148-
},
149-
{
150-
"value": "anthropic/claude-3-opus-20240229",
151-
"variables": "ANTHROPIC_API_KEY"
152-
},
153-
{
154-
"value": "anthropic/claude-3-sonnet-20240229",
155-
"variables": "ANTHROPIC_API_KEY"
156-
},
157-
{
158-
"value": "anthropic/claude-instant-1.2",
159-
"variables": "ANTHROPIC_API_KEY"
160-
},
161-
{
162-
"value": "fireworks/gemma2-9b-it",
163-
"variables": "FIREWORKS_API_KEY"
164-
},
165-
{
166-
"value": "fireworks/llama-v3-70b-instruct",
167-
"variables": "FIREWORKS_API_KEY"
168-
},
169-
{
170-
"value": "fireworks/llama-v3-70b-instruct-hf",
171-
"variables": "FIREWORKS_API_KEY"
172-
},
173-
{
174-
"value": "fireworks/llama-v3-8b-instruct",
175-
"variables": "FIREWORKS_API_KEY"
176-
},
177-
{
178-
"value": "fireworks/llama-v3-8b-instruct-hf",
179-
"variables": "FIREWORKS_API_KEY"
180-
},
181-
{
182-
"value": "fireworks/llama-v3p1-405b-instruct",
183-
"variables": "FIREWORKS_API_KEY"
184-
},
185-
{
186-
"value": "fireworks/llama-v3p1-405b-instruct-long",
187-
"variables": "FIREWORKS_API_KEY"
188-
},
189-
{
190-
"value": "fireworks/llama-v3p1-70b-instruct",
191-
"variables": "FIREWORKS_API_KEY"
192-
},
193-
{
194-
"value": "fireworks/llama-v3p1-8b-instruct",
195-
"variables": "FIREWORKS_API_KEY"
196-
},
197-
{
198-
"value": "fireworks/mixtral-8x22b-instruct",
199-
"variables": "FIREWORKS_API_KEY"
200-
},
201-
{
202-
"value": "fireworks/mixtral-8x7b-instruct",
203-
"variables": "FIREWORKS_API_KEY"
204-
},
205-
{
206-
"value": "fireworks/mixtral-8x7b-instruct-hf",
207-
"variables": "FIREWORKS_API_KEY"
208-
},
209-
{
210-
"value": "fireworks/mythomax-l2-13b",
211-
"variables": "FIREWORKS_API_KEY"
212-
},
213-
{
214-
"value": "fireworks/phi-3-vision-128k-instruct",
215-
"variables": "FIREWORKS_API_KEY"
216-
},
217-
{
218-
"value": "fireworks/phi-3p5-vision-instruct",
219-
"variables": "FIREWORKS_API_KEY"
220-
},
221-
{
222-
"value": "fireworks/starcoder-16b",
223-
"variables": "FIREWORKS_API_KEY"
224-
},
225-
{
226-
"value": "fireworks/yi-large",
227-
"variables": "FIREWORKS_API_KEY"
228-
},
229-
{
230-
"value": "openai/gpt-3.5-turbo",
231-
"variables": "OPENAI_API_KEY"
232-
},
233-
{
234-
"value": "openai/gpt-3.5-turbo-0125",
235-
"variables": "OPENAI_API_KEY"
236-
},
237-
{
238-
"value": "openai/gpt-3.5-turbo-0301",
239-
"variables": "OPENAI_API_KEY"
240-
},
241-
{
242-
"value": "openai/gpt-3.5-turbo-0613",
243-
"variables": "OPENAI_API_KEY"
244-
},
245-
{
246-
"value": "openai/gpt-3.5-turbo-1106",
247-
"variables": "OPENAI_API_KEY"
248-
},
249-
{
250-
"value": "openai/gpt-3.5-turbo-16k",
251-
"variables": "OPENAI_API_KEY"
252-
},
253-
{
254-
"value": "openai/gpt-3.5-turbo-16k-0613",
255-
"variables": "OPENAI_API_KEY"
256-
},
257-
{
258-
"value": "openai/gpt-4",
259-
"variables": "OPENAI_API_KEY"
260-
},
261-
{
262-
"value": "openai/gpt-4-0125-preview",
263-
"variables": "OPENAI_API_KEY"
264-
},
265-
{
266-
"value": "openai/gpt-4-0314",
267-
"variables": "OPENAI_API_KEY"
268-
},
269-
{
270-
"value": "openai/gpt-4-0613",
271-
"variables": "OPENAI_API_KEY"
272-
},
273-
{
274-
"value": "openai/gpt-4-1106-preview",
275-
"variables": "OPENAI_API_KEY"
276-
},
277-
{
278-
"value": "openai/gpt-4-32k",
279-
"variables": "OPENAI_API_KEY"
280-
},
281-
{
282-
"value": "openai/gpt-4-32k-0314",
283-
"variables": "OPENAI_API_KEY"
284-
},
285-
{
286-
"value": "openai/gpt-4-32k-0613",
287-
"variables": "OPENAI_API_KEY"
288-
},
289-
{
290-
"value": "openai/gpt-4-turbo",
291-
"variables": "OPENAI_API_KEY"
292-
},
293-
{
294-
"value": "openai/gpt-4-turbo-preview",
295-
"variables": "OPENAI_API_KEY"
296-
},
297-
{
298-
"value": "openai/gpt-4-vision-preview",
299-
"variables": "OPENAI_API_KEY"
300-
},
301-
{
302-
"value": "openai/gpt-4o",
303-
"variables": "OPENAI_API_KEY"
304-
},
305-
{
306-
"value": "openai/gpt-4o-mini",
307-
"variables": "OPENAI_API_KEY"
308-
}
309-
]
310-
},
311-
"scraper_tool_model_name": {
312-
"type": "string",
313-
"default": "accounts/fireworks/models/firefunction-v2",
127+
"description": "The name of the language model to use for the agent's main interactions. Should be in the form: provider/model-name.",
314128
"environment": [
315129
{
316130
"value": "anthropic/claude-1.2",

src/react_agent/configuration.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,28 @@
1414
class Configuration:
1515
"""The configuration for the agent."""
1616

17-
system_prompt: str = field(default=prompts.SYSTEM_PROMPT)
18-
"""The system prompt to use for the agent's interactions.
19-
20-
This prompt sets the context and behavior for the agent.
21-
"""
22-
23-
model_name: Annotated[str, {"__template_metadata__": {"kind": "llm"}}] = (
24-
"anthropic/claude-3-5-sonnet-20240620"
17+
system_prompt: str = field(
18+
default=prompts.SYSTEM_PROMPT,
19+
metadata={
20+
"description": "The system prompt to use for the agent's interactions. "
21+
"This prompt sets the context and behavior for the agent."
22+
},
23+
)
24+
25+
model_name: Annotated[str, {"__template_metadata__": {"kind": "llm"}}] = field(
26+
default="anthropic/claude-3-5-sonnet-20240620",
27+
metadata={
28+
"description": "The name of the language model to use for the agent's main interactions. "
29+
"Should be in the form: provider/model-name."
30+
},
31+
)
32+
33+
max_search_results: int = field(
34+
default=10,
35+
metadata={
36+
"description": "The maximum number of search results to return for each search query."
37+
},
2538
)
26-
"""The name of the language model to use for the agent's main interactions.
27-
28-
Should be in the form: provider/model-name.
29-
"""
30-
31-
scraper_tool_model_name: Annotated[
32-
str, {"__template_metadata__": {"kind": "llm"}}
33-
] = "accounts/fireworks/models/firefunction-v2"
34-
"""The name of the language model to use for the web scraping tool.
35-
36-
This model is specifically used for summarizing and extracting information from web pages.
37-
"""
38-
max_search_results: int = 10
39-
"""The maximum number of search results to return for each search query."""
4039

4140
@classmethod
4241
def from_runnable_config(

src/react_agent/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ def route_model_output(state: State) -> Literal["__end__", "tools"]:
125125
interrupt_before=[], # Add node names here to update state before they're called
126126
interrupt_after=[], # Add node names here to update state after they're called
127127
)
128-
graph.name = "ReAct Agent" # This customizes the name in LangSmith
128+
graph.name = "ReAct Agent" # This customizes the name in LangSmith

src/react_agent/tools.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,19 @@
11
"""This module provides example tools for web scraping and search functionality.
22
3-
It includes:
4-
- A web scraper that uses an LLM to summarize content based on instructions
5-
- A basic Tavily search function
3+
It includes a basic Tavily search function (as an example)
64
75
These tools are intended as free examples to get started. For production use,
86
consider implementing more robust and specialized tools tailored to your needs.
97
"""
108

11-
from datetime import datetime, timezone
129
from typing import Any, Callable, List, Optional, cast
1310

14-
import httpx
15-
from langchain.chat_models import init_chat_model
1611
from langchain_community.tools.tavily_search import TavilySearchResults
1712
from langchain_core.runnables import RunnableConfig
1813
from langchain_core.tools import InjectedToolArg
1914
from typing_extensions import Annotated
2015

2116
from react_agent.configuration import Configuration
22-
from react_agent.utils import get_message_text
23-
24-
25-
# note that arguments typed as "RunnableConfig" in tools will be excluded from the schema generated
26-
# for the model.
27-
# They are treated as "injected arguments"
28-
async def scrape_webpage(url: str, instructions: str, *, config: RunnableConfig) -> str:
29-
"""Scrape the given webpage and return a summary of text based on the instructions.
30-
31-
Args:
32-
url: The URL of the webpage to scrape.
33-
instructions: The instructions to give to the scraper. An LLM will be used to respond using the
34-
instructions and the scraped text.
35-
"""
36-
async with httpx.AsyncClient() as client:
37-
response = await client.get(url)
38-
web_text = response.text
39-
40-
configuration = Configuration.from_runnable_config(config)
41-
model = init_chat_model(configuration.model_name)
42-
response_msg = await model.ainvoke(
43-
[
44-
(
45-
"system",
46-
"You are a helpful web scraper AI assistant. You are working in extractive Q&A mode, meaning you refrain from making overly abstractive responses."
47-
"Respond to the user's instructions."
48-
" Based on the provided webpage. If you are unable to answer the question, let the user know. Do not guess."
49-
" Provide citations and direct quotes when possible."
50-
f" \n\n<webpage_text>\n{web_text}\n</webpage_text>"
51-
f"\n\nSystem time: {datetime.now(tz=timezone.utc)}",
52-
),
53-
("user", instructions),
54-
]
55-
)
56-
return get_message_text(response_msg)
5717

5818

5919
async def search(
@@ -71,4 +31,4 @@ async def search(
7131
return cast(list[dict[str, Any]], result)
7232

7333

74-
TOOLS: List[Callable[..., Any]] = [scrape_webpage, search]
34+
TOOLS: List[Callable[..., Any]] = [search]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from react_agent.configuration import Configuration
22

33

4-
def test_configuration_empty():
4+
def test_configuration_empty() -> None:
55
Configuration.from_runnable_config({})

0 commit comments

Comments
 (0)