-
Notifications
You must be signed in to change notification settings - Fork 231
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
feat: Add Voyage AI support #575
base: main
Are you sure you want to change the base?
Conversation
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
Add "(aside)" to your comment to have me ignore it. |
Codecov ReportAttention: Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…tests Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
…r handling - Add async embedding support - Improve error handling and logging - Add token counting from usage data - Enhance type hints - Maintain Python version warning Fixes #461 Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
- Replace incorrect [external] and [tool.tach.dependencies] with [dependency-group.ci] - Keep existing module configurations intact - Fix 'Group ci is not defined' error Part of #461 Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
14864488 | Triggered | Generic High Entropy Secret | ad922f8 | examples/voyage/voyage_example.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
examples/voyage/voyage_example.py
Outdated
def main(): | ||
# Set AgentOps API key | ||
os.environ["AGENTOPS_API_KEY"] = "8b95388c-ee56-499d-a940-c1d6a2ba7f0c" | ||
|
||
# Initialize clients | ||
voyage_client = MockVoyageClient() | ||
ao_client = AgentopsClient() | ||
|
||
# Initialize session | ||
session = ao_client.initialize() |
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.
🤖 Bug Fix:
Avoid Hardcoding API Keys
Hardcoding API keys directly in the code poses a significant security risk. It can lead to unauthorized access if the code is exposed in version control or logs.
- Store the API key in a secure environment variable or a configuration file that is not included in version control.
- Access the API key using
os.environ
or a secure configuration management tool. - This approach enhances security and prevents potential misuse of the API. 🔒
🔧 Suggested Code Diff:
import os
def main():
# Set AgentOps API key from environment variable
api_key = os.getenv("AGENTOPS_API_KEY")
if not api_key:
raise ValueError("API key not found. Please set the AGENTOPS_API_KEY environment variable.")
os.environ["AGENTOPS_API_KEY"] = api_key
# Initialize clients
voyage_client = MockVoyageClient()
ao_client = AgentopsClient()
# Initialize session
session = ao_client.initialize()
print(f"Session URL: {session.session_url}")
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
def main(): | |
# Set AgentOps API key | |
os.environ["AGENTOPS_API_KEY"] = "8b95388c-ee56-499d-a940-c1d6a2ba7f0c" | |
# Initialize clients | |
voyage_client = MockVoyageClient() | |
ao_client = AgentopsClient() | |
# Initialize session | |
session = ao_client.initialize() | |
import os | |
def main(): | |
# Set AgentOps API key from environment variable | |
api_key = os.getenv("AGENTOPS_API_KEY") | |
if not api_key: | |
raise ValueError("API key not found. Please set the AGENTOPS_API_KEY environment variable.") | |
os.environ["AGENTOPS_API_KEY"] = api_key | |
# Initialize clients | |
voyage_client = MockVoyageClient() | |
ao_client = AgentopsClient() | |
# Initialize session | |
session = ao_client.initialize() | |
print(f"Session URL: {session.session_url}") |
📜 Guidelines
- Use exceptions for error handling, but avoid assert statements for critical logic.
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
examples/voyage/voyage_example.py
Outdated
def main(): | ||
# Set AgentOps API key | ||
os.environ["AGENTOPS_API_KEY"] = "8b95388c-ee56-499d-a940-c1d6a2ba7f0c" | ||
|
||
# Initialize clients | ||
voyage_client = MockVoyageClient() | ||
ao_client = AgentopsClient() | ||
|
||
# Initialize session | ||
session = ao_client.initialize() | ||
print(f"Session URL: {session.session_url}") | ||
|
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.
🤖 Bug Fix:
Remove Hardcoded API Key
Hardcoding API keys in the code is a significant security risk. It can lead to unauthorized access if the code is exposed. Instead, retrieve the API key from a secure environment variable. This approach enhances security and makes the code more flexible for different environments.
🔧 Suggested Code Diff:
-def main():
- # Set AgentOps API key
- os.environ["AGENTOPS_API_KEY"] = "8b95388c-ee56-499d-a940-c1d6a2ba7f0c"
+def main():
+ # Retrieve AgentOps API key from environment variable
+ api_key = os.environ.get("AGENTOPS_API_KEY")
+ if not api_key:
+ raise ValueError("AGENTOPS_API_KEY environment variable not set")
+ os.environ["AGENTOPS_API_KEY"] = api_key
# Initialize clients
voyage_client = MockVoyageClient()
ao_client = AgentopsClient()
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
def main(): | |
# Set AgentOps API key | |
os.environ["AGENTOPS_API_KEY"] = "8b95388c-ee56-499d-a940-c1d6a2ba7f0c" | |
# Initialize clients | |
voyage_client = MockVoyageClient() | |
ao_client = AgentopsClient() | |
# Initialize session | |
session = ao_client.initialize() | |
print(f"Session URL: {session.session_url}") | |
def main(): | |
# Retrieve AgentOps API key from environment variable | |
api_key = os.environ.get("AGENTOPS_API_KEY") | |
if not api_key: | |
raise ValueError("AGENTOPS_API_KEY environment variable not set") | |
os.environ["AGENTOPS_API_KEY"] = api_key | |
# Initialize clients | |
voyage_client = MockVoyageClient() | |
ao_client = AgentopsClient() | |
# Initialize session | |
session = ao_client.initialize() | |
print(f"Session URL: {session.session_url}") |
📜 Guidelines
Python: Avoid mutable global states
- Apply automatic formatting fixes from ruff - Ensure code meets project style guidelines Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
examples/voyage/voyage_example.py
Outdated
def record(self, event): | ||
"""Record event with minimal data exposure.""" | ||
try: | ||
event_data = { | ||
"type": "llms", | ||
"model": "default", | ||
"input_tokens": 10, | ||
"output_tokens": 0, | ||
"input": getattr(event, "input", ""), |
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.
🤖 Bug Fix:
Syntax Error Due to Missing Comma
There is a missing comma between the 'input_tokens' and 'output_tokens' keys in the dictionary definition within the record
method. This will cause a syntax error, preventing the code from executing correctly. Please add the missing comma to resolve this issue. 🛠️
🔧 Suggested Code Diff:
event_data = {
"type": "llms",
"model": "default",
"input_tokens": 10,
"output_tokens": 0,
"input": getattr(event, "input", ""),
"output": {
"type": "embedding",
"data": ["<vector data redacted>"],
},
"metadata": {"text": getattr(event, "input", "")},
}
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
def record(self, event): | |
"""Record event with minimal data exposure.""" | |
try: | |
event_data = { | |
"type": "llms", | |
"model": "default", | |
"input_tokens": 10, | |
"output_tokens": 0, | |
"input": getattr(event, "input", ""), | |
def record(self, event): | |
"""Record event with minimal data exposure.""" | |
try: | |
event_data = { | |
"type": "llms", | |
"model": "default", | |
"input_tokens": 10, | |
"output_tokens": 0, | |
"input": getattr(event, "input", ""), | |
"output": { | |
"type": "embedding", | |
"data": ["<vector data redacted>"], | |
}, | |
"metadata": {"text": getattr(event, "input", "")}, | |
} | |
# Further processing of event_data can be done here | |
except Exception as e: | |
# Handle exceptions appropriately | |
print(f"An error occurred: {e}") |
🔍 Learnings
NA
📜 Guidelines
• Follow PEP 8 style guidelines
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
Voyage AI Integration Updates
Changes
Testing
Tested locally with mock client
Verified event data fields are properly populated:
Session Verification
Latest test session: https://app.agentops.ai/drilldown?session_id=174f739f-30bf-4a1d-933a-2a30b10e7000
Link to Devin run: https://app.devin.ai/sessions/97458294b13e45849dea480c9ed52ef7
Closes #461