This documentation describes the integration of MindsDB with Portkey, an AI Gateway that allows developers to connect to All the AI models in the world with a single API.
Portkey also brings in observability, caching, and other features that are useful for building production-grade AI applications.
You can pass all the parameters that are supported by Portkey inside the USING clause.
Copy
Ask AI
CREATE ML_ENGINE portkey_engineFROM portkeyUSING portkey_api_key = '{PORTKEY_API_KEY}', -- get this from Portkey dashboard (https://app.portkey.ai/api-keys) config = '{PORTKEY_CONFIG_ID}'; -- get this from Portkey dashboard (https://app.portkey.ai/configs)
Create a model using portkey_engine as an engine.
You can pass all the parameters supported by Portkey Chat completions here inside the USING clause.
refer Portkey Chat completions for more details.
Copy
Ask AI
CREATE MODEL portkey_modelPREDICT answerUSING engine = 'portkey_engine', model = 'gpt-3.5-turbo', temperature = 0.2;
The integrations between Portkey and MindsDB was implemented using Portkey Python SDK.
Query the model to get predictions.
Copy
Ask AI
SELECT question, answerFROM portkey_modelWHERE question = 'Where is Stockholm located?';
Here is the output:
Copy
Ask AI
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+| question | answer |+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+| Where is Stockholm located? | Stockholm is the capital and largest city of Sweden. It is located on Sweden's south-central east coast, where Lake Mälaren meets the Baltic Sea. |+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
This example demonstrates how to create a model to summarize text using Portkey:
Copy
Ask AI
CREATE MODEL summarization_modelPREDICT summaryUSING engine = 'portkey_engine', model = 'gpt-3.5-turbo', temperature = 0.5, max_tokens = 100;SELECT document, summaryFROM summarization_modelWHERE document = 'MindsDB is a predictive platform that connects machine learning models with databases.';
CREATE MODEL sentiment_modelPREDICT sentimentUSING engine = 'portkey_engine', model = 'gpt-3.5-turbo', temperature = 0.3;SELECT review, sentimentFROM sentiment_modelWHERE review = 'The product was excellent and exceeded expectations!';
CREATE MODEL translation_modelPREDICT translationUSING engine = 'portkey_engine', model = 'gpt-3.5-turbo', temperature = 0.4;SELECT original_text, translationFROM translation_modelWHERE original_text = 'Hello, how are you?' AND target_language = 'es';
CREATE MODEL extraction_modelPREDICT extracted_dataUSING engine = 'portkey_engine', model = 'gpt-3.5-turbo', temperature = 0.6;SELECT text, extracted_dataFROM extraction_modelWHERE text = 'Minds , 35, lives in New York and works as a software engineer.';
Next StepsGo to the Use Cases section to see more examples.