-
Notifications
You must be signed in to change notification settings - Fork 0
Working Example #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Working Example #15
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,32 +30,28 @@ from ionic_langchain.tool import IonicTool | |
| from langchain.agents import AgentType, Tool | ||
| from langchain.agents import initialize_agent | ||
| from langchain.chat_models import ChatOpenAI | ||
| from langchain.memory import ConversationBufferWindowMemory, RedisChatMessageHistory | ||
|
|
||
|
|
||
| tools: List[Tool] = [ | ||
| tools = [ | ||
| IonicTool().tool(), | ||
| # others, | ||
| # your other tools, | ||
| ] | ||
| redis_memory = RedisChatMessageHistory(url=os.environ.get("REDIS_URL"),session_id="chatId"), | ||
| memory = ConversationBufferWindowMemory( | ||
| k=12, | ||
| return_messages=True, | ||
| chat_memory=redis_memory, | ||
| memory_key="chat_history", | ||
| ) | ||
|
|
||
| agent = initialize_agent( | ||
| tools=tools, | ||
| llm=ChatOpenAI(openai_api_key=os.environ.get("OPENAI_API_KEY"),temperature=0.5), | ||
| agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, | ||
| memory=memory, | ||
| llm=ChatOpenAI(openai_api_key="your_key_here", temperature=0.7), | ||
| agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, | ||
| handle_parsing_errors=True, | ||
| verbose=True, | ||
| ) | ||
|
|
||
| agent.run(input="Roadhouse VHS") | ||
|
|
||
| input = "Where can I get tide pods" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hiding somewhere in your child's room
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| agent.run(input=input) | ||
| ``` | ||
|
|
||
| _Please see the [langchain agent docs](https://python.langchain.com/docs/modules/agents/) for more details on how to build and run agents_ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. underscore?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh that's italicization, carry on |
||
|
|
||
| ### Customizing the SDK | ||
|
|
||
| `ionic_langchain.tool.IonicTool`'s constructor accepts an instance of `ionic_langchain.tool.Ionic`, a wrapper around [our SDK](https://pypi.org/project/Ionic-API-SDK/). `ionic_langchain.tool.Ionic`, in turn accepts an instance of that SDK, so you can provide the tool with a custom configuration: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change our impl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in our agent? no that works because it has redis, etc.