Skip to content

Curl commands

IntelliNode edited this page Sep 9, 2023 · 4 revisions

Chatbot

The chatbot is available with multiple providers, below is an example of the calling openai model:

curl --location 'http://localhost/chatbot/chat' \
--header 'X-API-KEY: <microservice-key>' \
--header 'Content-Type: application/json' \
--data '{
   "api_key": "<openai-key>",
   "model": "gpt4",
   "provider": "openai",
    "input": {
        "system": "You are a helpful assistant.",
        "messages": [
            {
            "role": "user",
            "content": "recommend a vegetarian dish for dinner"
            }
        ]
    }
}'

You can also use llama v2 from Replicate with the same input format by replacing:

  • provider: replicate
  • model: 13b-chat or 70b-chat

Semantic Search

Advanced search capabilities are provided by openai or cohere providers using embedding vector and cosine similarity, with a unified input format from the intelliserver layer.

curl --location 'http://localhost/semanticsearch/search' \
--header 'X-API-KEY: <microservice-key>' \
--header 'Content-Type: application/json' \
--data '{
   "api_key": "<cohere-key>",
   "provider": "openai",
    "input": {
        "pivot_item": "Hello from OpenAI!",
       "search_array": ["Greetings from OpenAI!", "Bonjour de OpenAI!", "Hola desde OpenAI!"],
       "number_of_matches": 2
    }
}'

You can also use openai for the semantic search by replacing:

  • provider: openai

LLM Evaluation

You can run evaluations across multiple models and select the suitable model for your use case based on quantitive methods. Below is an example to compare llama 13b-chat, openai gpt-3.5, and cohere command models.

curl --location 'http://localhost/evaluate/llm' \
--header 'X-API-KEY: <microservice-key>' \
--header 'Content-Type: application/json' \
--data '{
  "userInput": "Explain the process of photosynthesis in simple terms.",
  "targetAnswers": [
    "Photosynthesis is the process where green plants use sunlight to turn carbon dioxide and water into glucose and oxygen.",
    "Photosynthesis is how plants make their own food. They take in water and carbon dioxide, use the energy from sunlight to transform them into glucose and oxygen.",
    "In simple terms, photosynthesis is like cooking for plants but instead of a stove, they use sunlight. They mix water and carbon dioxide with the sunlight to create glucose, which is their food, and also produce oxygen."
  ],
  "semantic": {
    "api_key": "",
    "provider": "openai"
  },
  "evaluate": [
    {
      "apiKey": "",
      "provider": "replicate",
      "type": "chat",
      "model": "13b-chat",
      "maxTokens": 50
    },
    {
      "apiKey": "",
      "provider": "cohere",
      "type": "completion",
      "model": "command",
      "maxTokens": 50
    },
    {
      "apiKey": "",
      "provider": "openai",
      "type": "chat",
      "model": "gpt-3.5-turbo",
      "maxTokens": 50,
      "temperature": 0.7
    }
  ]
}'

Replace the <microservice-key> with the provided microservice key when running the docker image.

Clone this wiki locally