Skip to content

Commit ee19faf

Browse files
Update to v0.1.7
1 parent ce61997 commit ee19faf

File tree

6 files changed

+584
-5
lines changed

6 files changed

+584
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ gr.ChatInterface(
8282
- **v0.1.2** : Fixed a display bug in the **web_front** and experimentally added **ollama as a backend**
8383
- **v0.1.3** : Fixed the memory reset in the **web_front** and remove **ollama module** for **openai front** (work 100 times better)
8484
- **v0.1.4** : Fixed `web_front` for native use on huggingface, as well as `handle_streaming` which had tool retrieval issues
85-
- **v0.1.5** : Added a **TUI** and **commands**, detection of **env variables** (API keys) and tools in the framework
85+
- **v0.1.7** : Added a **TUI** and **commands**, detection of **env variables** (API keys) and tools in the framework
8686

8787
## Advanced Examples
8888

8989
- [tools call in a JSON database](https://github.com/SyntaxError4Life/open-taranis/blob/main/examples/test_json_database.py)
9090
- [tools call in a HR JSON database in multi-rounds](https://github.com/SyntaxError4Life/open-taranis/blob/main/examples/test_HR_json_database.py)
91+
- [simple search agent with Brave API](https://github.com/SyntaxError4Life/open-taranis/blob/main/examples/brave_research.py)
9192

9293
## Links
9394

9495
- [PyPI](https://pypi.org/project/open-taranis/)
95-
- [GitHub Repository](https://github.com/SyntaxError4Life/open-taranis)
96+
- [GitHub Repository](https://github.com/SyntaxError4Life/open-taranis)

examples/brave_research.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1+
import open_taranis as T
2+
from open_taranis.tools import brave_research, fast_scraping
13

4+
client = T.clients.openrouter(api_key=None)
5+
request = T.clients.openrouter_request
6+
7+
messages = [
8+
T.create_system_prompt("""You are an autonomous AI web search agent.
9+
For example, you can search for URLs in Brave and scrape them to obtain all their content.
10+
11+
Don't hesitate to conduct in-depth searches, such as navigating from site to site using the URLs you find there, and so on.
12+
Make as many function calls as needed for the tasks the user assigns you.
13+
You must execute them flawlessly and never cheat; complete your mission successfully!"""),
14+
T.create_user_prompt(input("Request : "))
15+
]
16+
17+
run = True
18+
19+
while run :
20+
respond=""
21+
22+
for token, tool_calls, run in T.handle_streaming(request(
23+
client=client,messages=messages,model="nvidia/nemotron-3-nano-30b-a3b:free",
24+
tools=T.functions_to_tools([brave_research,fast_scraping])
25+
)):
26+
if token :
27+
print(token, end="")
28+
respond+=token
29+
30+
if run :
31+
messages.append(T.create_assistant_response(respond, tool_calls))
32+
33+
for tool_call in tool_calls :
34+
fid, fname, args, _ = T.handle_tool_call(tool_call)
35+
tool_response=""
36+
37+
if fname == "brave_research":
38+
39+
print(f"\nSearch on Brave : {args["web_request"]} \n")
40+
41+
results=brave_research(
42+
web_request=args["web_request"],
43+
count=5,
44+
country="fr"
45+
)
46+
47+
for item in results["web"]["results"]:
48+
tool_response+= f"{item['title']} : {item['url']}\n"
49+
50+
if fname == "fast_scraping":
51+
52+
print(f"\nScraping {args["url"]}\n")
53+
tool_response=fast_scraping(url=args["url"])
54+
55+
56+
messages.append(T.create_function_response(
57+
id=fid,result=tool_response,name=fname
58+
))
59+
60+
if not run :
61+
messages.append(T.create_assistant_response(respond))

img/.g

Whitespace-only changes.

0 commit comments

Comments
 (0)