-
Notifications
You must be signed in to change notification settings - Fork 30
Creating an logger for tools and chain #90
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62e9587
setting the training data
jacobsanosh be8affc
formatting the files
jacobsanosh 1b2827e
formatting the files
jacobsanosh de011b1
setting up command line execution for logger
jacobsanosh 4ec2662
fixing comments
jacobsanosh 1bfb829
Fix for training data generation script
vizsatiz c66aff2
Merge branch 'develop' into fixer
vizsatiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,6 @@ bin | |
| *.sql | ||
| *.log | ||
| *.yaml | ||
| examples/local/* | ||
| .logs | ||
| scratch_pad.py | ||
| examples/local/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import os | ||
| from langchain_openai import ChatOpenAI | ||
| from langchain_core.prompts import PromptTemplate | ||
| from flo_ai.callbacks import FloExecutionLogger | ||
| from flo_ai.storage.data_collector import JSONLFileCollector | ||
| from flo_ai import Flo, FloSession | ||
| from flo_ai.models.flo_agent import FloAgent | ||
| from langchain_community.tools.tavily_search.tool import TavilySearchResults | ||
| from dotenv import load_dotenv | ||
|
|
||
|
|
||
| load_dotenv() | ||
|
|
||
| file_collector = JSONLFileCollector('.logs') | ||
|
|
||
| # Create a tool logger with the collector | ||
| local_tracker = FloExecutionLogger(file_collector) | ||
| # Create the LLM object | ||
| llm = ChatOpenAI(temperature=0, model_name='gpt-4o-mini') | ||
|
|
||
|
|
||
| prompt = PromptTemplate.from_template('1 + {number} = ') | ||
|
|
||
| chain = prompt | llm | ||
| print(chain.invoke({'number': 2})) | ||
|
|
||
|
|
||
| session = FloSession(llm) | ||
| session.register_callback(local_tracker) | ||
|
|
||
| os.environ['TAVILY_API_KEY'] = os.getenv('TAVILY_API_KEY') | ||
| tavily_tool = TavilySearchResults() | ||
|
|
||
| session.register_tool('thappal', tavily_tool) | ||
|
|
||
| weather_agent = FloAgent.create( | ||
| session=session, | ||
| name='Blogger', | ||
| job='You can research the internet and create a blog about the topic given by the user', | ||
| tools=[tavily_tool], | ||
| ) | ||
|
|
||
|
|
||
| agent_flo: Flo = Flo.create(session, weather_agent) | ||
|
|
||
| print(agent_flo.invoke('Whats the whether in New Delhi, India ?')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.