-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from MervinPraison/develop
Update PraisonAI to version 2.0.56 and enhance agent functionality
- Loading branch information
Showing
28 changed files
with
2,130 additions
and
274 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM python:3.11-slim | ||
WORKDIR /app | ||
COPY . . | ||
RUN pip install flask praisonai==2.0.55 gunicorn markdown | ||
RUN pip install flask praisonai==2.0.56 gunicorn markdown | ||
EXPOSE 8080 | ||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"] |
This file contains 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,45 @@ | ||
from praisonaiagents import Agent | ||
|
||
# Detailed LLM configuration | ||
llm_config = { | ||
"model": "gemini/gemini-1.5-flash-latest", # Model name without provider prefix | ||
|
||
# Core settings | ||
"temperature": 0.7, # Controls randomness (like temperature) | ||
"timeout": 30, # Timeout in seconds | ||
"top_p": 0.9, # Nucleus sampling parameter | ||
"max_tokens": 1000, # Max tokens in response | ||
|
||
# Advanced parameters | ||
"presence_penalty": 0.1, # Penalize repetition of topics (-2.0 to 2.0) | ||
"frequency_penalty": 0.1, # Penalize token repetition (-2.0 to 2.0) | ||
|
||
# API settings (optional) | ||
"api_key": None, # Your API key (or use environment variable) | ||
"base_url": None, # Custom API endpoint if needed | ||
|
||
# Response formatting | ||
"response_format": { # Force specific response format | ||
"type": "text" # Options: "text", "json_object" | ||
}, | ||
|
||
# Additional controls | ||
"seed": 42, # For reproducible responses | ||
"stop_phrases": ["##", "END"], # Custom stop sequences | ||
} | ||
|
||
agent = Agent( | ||
instructions="You are a helpful Assistant specialized in scientific explanations. " | ||
"Provide clear, accurate, and engaging responses.", | ||
llm=llm_config, # Pass the detailed configuration | ||
verbose=True, # Enable detailed output | ||
markdown=True, # Format responses in markdown | ||
self_reflect=True, # Enable self-reflection | ||
max_reflect=3, # Maximum reflection iterations | ||
min_reflect=1 # Minimum reflection iterations | ||
) | ||
|
||
# Test the agent | ||
response = agent.start("Why is the sky blue? Please explain in simple terms.") | ||
|
||
print(response) |
This file contains 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,18 @@ | ||
import asyncio | ||
from praisonaiagents import Agent | ||
|
||
async def main(): | ||
agent = Agent( | ||
instructions="You are a helpful assistant", | ||
llm="gemini/gemini-1.5-flash-8b", | ||
self_reflect=True, | ||
verbose=True | ||
) | ||
|
||
# Use achat instead of start/chat for async operation | ||
response = await agent.achat("Why sky is Blue in 1000 words?") | ||
print(response) | ||
|
||
if __name__ == "__main__": | ||
# Run the async main function | ||
asyncio.run(main()) |
This file contains 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,10 @@ | ||
from praisonaiagents import Agent | ||
|
||
agent = Agent( | ||
instructions="You are a helpful assistant", | ||
llm="gemini/gemini-1.5-flash-8b", | ||
self_reflect=True, | ||
verbose=True | ||
) | ||
|
||
agent.start("Why sky is Blue?") |
This file contains 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 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 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,8 @@ | ||
from praisonaiagents import Agent | ||
|
||
agent = Agent( | ||
instructions="You are a helpful assistant", | ||
llm="gpt-4o-mini" | ||
) | ||
|
||
agent.start("Why sky is Blue?") |
Oops, something went wrong.