Created
          February 17, 2025 11:49 
        
      - 
      
- 
        Save vrushankportkey/3b8c3e4cf289f600f2d6f6b06bb7d0ed to your computer and use it in GitHub Desktop. 
    Portkey Prompt Template 
  
        
  
    
      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
    
  
  
    
  | from portkey_ai import Portkey | |
| portkey_tools = [] | |
| portkey_tool = { | |
| "type": "function", | |
| "function": { | |
| "name": "get_weather", | |
| "description": "Get current temperature for a given location.", | |
| "parameters": { | |
| "type": "object", | |
| "properties": { | |
| "location": { | |
| "type": "string", | |
| "description": "City and country e.g. Bogotá, Colombia" | |
| } | |
| }, | |
| "required": ["location"] | |
| } | |
| } | |
| } | |
| portkey_tools.append(portkey_tool) | |
| client = Portkey( | |
| api_key="....." | |
| ) | |
| chat_history = [ | |
| { | |
| "content": "What's the weather in Dilli?", | |
| "role": "user" | |
| } | |
| ] | |
| prompt_completion = client.with_options( | |
| trace_id="prompt-tools-stream", | |
| span_id="llm_call", | |
| span_name="llm", | |
| parent_span_id="test_call").prompts.completions.create( | |
| prompt_id="pp-planyear-s-fbf233", | |
| variables={"chat_history": chat_history}, | |
| tools=portkey_tools, | |
| tools_choice="auto", | |
| stream=True | |
| ) | |
| for chunk in prompt_completion: | |
| print(chunk.choices[0].delta) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment