mobarski / ai-bricks Goto Github PK
View Code? Open in Web Editor NEWAI adapters / facade
License: MIT License
AI adapters / facade
License: MIT License
I have tried to use both your react/v3 agent, and your v2 agent, without luck. The model just keeps repeating itself, even if it has the answer. I am using Claude
Code
import time
from ai_bricks.api import openai
from ai_bricks.api import anthropic
from ai_bricks import agent
aa = agent.actions
aa.wikipedia_search_many.__name__ = 'wikipedia-summary'
aa.wikipedia_get_data.__name__ = 'wikipedia-data'
actions = [
aa.wikipedia_search_many,
aa.wikipedia_get_data,
aa.python_eval,
]
q = "What is two plus two"
model = anthropic.model('claude-instant-v1', temperature=0.0) # key from ANTHROPIC_API_KEY env variable
a = agent.get('react')(model=model, actions=actions)
answer = a.run(q, n_turns=3)
Output:
Task: Answer the following question as best you can.
Question: What is two plus two
You are augmented with the following actions:
- wikipedia-summary: query wikipedia with a list of entities / subjects and return a summary for each one
- wikipedia-data: query wikipedia with a list of entities / subjects and return the main data table for each one
- python_eval: evaluate single python expression; imported modules: math, time, random, datetime; do not import anything else; use only one line of code
Use the following response protocol and format:
Question: What is two plus two
Thought: you should always think about what to do
Action: the action to take (only the name, not the arguments)
Input: the input to the action
Observation: the result of the action
Summary: key takeways - extract all data (esp numeric data) relevant to the question, one item per line
Repeat:
- this Question/Thought/Action/Input/Observation/Summary can repeat N times
- if you don't want to take any action you can skip from one Thought to the next Thought
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Important:
- always follow the protocol - Thought, Action, Input, Observation, Summary, Thought, etc
- never use empty Input
- you don't know current time and date
Thought: you should always think about what to do
Action: python_eval
Input: math.ceil(2+2)
---
CLEAR: 0
Observation: 4
Reminder: The next item must be a Summary followed by a Thought!
Thought: you should always think about what to do
Action: python_eval
Input: math.ceil(2+2)
---
CLEAR: 8
Observation: 4
Reminder: The next item must be a Summary followed by a Thought!
Thought: you should always think about what to do
Action: python_eval
Input: math.ceil(2+2)
---
CLEAR: 8
Observation: 4
Reminder: The next item must be a Summary followed by a Thought!
DONE IN 2.7s (3 steps, 0.90s per step) FOR $0.0027 (1264 claude-instant-v1 tokens)
Question: What is two plus two
Final Answer:
openai.proxy="balabala"
Hi! I was reviewing your ask-pdf app, but it wasn't working.
The problem is apparently in the ai_bricks/api/openai client, the API version has been deprecated recently.
You can check more info about the changes here: openai/openai-python#742
Nice code, btw.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.