Skip to content
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

[feature request] capture tool_schema in anthropic requests #1068

Closed
mikeldking opened this issue Oct 17, 2024 · 1 comment · Fixed by #1087
Closed

[feature request] capture tool_schema in anthropic requests #1068

mikeldking opened this issue Oct 17, 2024 · 1 comment · Fixed by #1087
Assignees
Labels
enhancement New feature or request language: python Related to Python integration

Comments

@mikeldking
Copy link
Contributor

see example:

from typing import Any, Dict
from your_client_library import Client  # Replace with actual import

tool_schema = {
    "name": "record_travel_request_attributes",
    "description": "Records the attributes of a travel request",
    "input_schema": {
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": 'The desired destination location. Use city, state, and country format when possible. If no destination is provided, return "not_stated".',
            },
            "budget_level": {
                "type": "string",
                "enum": ["low", "medium", "high", "not_stated"],
                "description": 'The desired budget level. If no budget level is provided, return "not_stated".',
            },
            "purpose": {
                "type": "string",
                "enum": ["business", "pleasure", "other", "not_stated"],
                "description": 'The purpose of the trip. If no purpose is provided, return "not_stated".',
            },
        },
        "required": ["location", "budget_level", "purpose"],
    },
}

system_message = (
    "You are an assistant that parses and records the attributes of a user's travel request."
)

def extract_raw_travel_request_attributes_string(
    travel_request: str,
    client: Client,
    model: str = "claude-3-5-sonnet-20240620",
) -> str:
    response = client.messages.create(
        model=model,
        max_tokens=1024,
        messages=[
            {"role": "user", "content": travel_request},
        ],
        system=system_message,
        tools=[tool_schema],
        tool_choice={"type": "tool", "name": "record_travel_request_attributes"},
    )
    # Process the response to extract the relevant information
    # This is a placeholder - you'll need to implement the actual extraction logic
    extracted_attributes = process_response(response)
    return extracted_attributes

def process_response(response: Any) -> str:
    # Implement the logic to extract the attributes from the response
    # This is a placeholder function
    pass
    ```
@mikeldking mikeldking added enhancement New feature or request triage Issues that require triage labels Oct 17, 2024
@github-project-automation github-project-automation bot moved this to 📘 Todo in phoenix Oct 17, 2024
@mikeldking
Copy link
Contributor Author

Related to playground

@dosubot dosubot bot added the language: python Related to Python integration label Oct 17, 2024
@axiomofjoy axiomofjoy removed the triage Issues that require triage label Oct 18, 2024
@axiomofjoy axiomofjoy moved this from 👨‍💻 In progress to 🔍. Needs Review in phoenix Oct 30, 2024
@github-project-automation github-project-automation bot moved this from 🔍. Needs Review to ✅ Done in phoenix Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language: python Related to Python integration
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants