example.py
1 from mlflow.deployments import get_deploy_client 2 3 4 def main(): 5 client = get_deploy_client("http://localhost:7000") 6 7 print(f"Togetherai endpoints: {client.list_endpoints()}\n") 8 print(f"Togetherai completions endpoint info: {client.get_endpoint(endpoint='completions')}\n") 9 print(f"Togetherai chat endpoint info: {client.get_endpoint(endpoint='chat')}\n") 10 print(f"Togetherai embeddings endpoint info: {client.get_endpoint(endpoint='embeddings')}\n") 11 12 response_completions = client.predict( 13 endpoint="completions", 14 inputs={ 15 "prompt": "Who is the protagonist in Witcher 3 Wild Hunt?", 16 "max_tokens": 200, 17 "temperature": 0.1, 18 }, 19 ) 20 21 print(f"Togetherai response for completions: {response_completions}") 22 23 response_embeddings = client.predict( 24 endpoint="embeddings", 25 inputs={ 26 "input": ["Who is Wes Montgomery?"], 27 }, 28 ) 29 30 print(f"Togetherai response for embeddings: {response_embeddings}") 31 32 response_chat = client.predict( 33 endpoint="chat", 34 inputs={ 35 "messages": [{"role": "user", "content": "Get out of the sunlight's way Alexander!"}], 36 }, 37 ) 38 39 print(f"Togetherai response for chat: {response_chat}") 40 41 42 if __name__ == "__main__": 43 main()