Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
vrushankportkey committed Sep 19, 2023
1 parent 0b98005 commit f2fdac8
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pip install portkey-ai

## **🚀 Quick Start**

### **4️⃣ Steps to Integrate the SDK**

**4️ Steps to Integrate the SDK**
1. Get your Portkey API key and your virtual key for AI providers.
2. Construct your LLM, add Portkey features, provider features, and prompt.
3. Construct the Portkey client and set your usage mode.
Expand All @@ -36,28 +35,25 @@ Let's dive in! If you are an advanced user and want to directly jump to various

---

### 1️⃣: Get your Portkey API Key and your Virtual Keys for AI providers
### **Step 1️⃣ : Get your Portkey API Key and your Virtual Keys for AI providers**

**Portkey API Key:** Log into [Portkey here](https://app.portkey.ai/), then click on the profile icon on top left and “Copy API Key”.
```py
```python
import os
os.environ["PORTKEY_API_KEY"] = "PORTKEY_API_KEY"
```
**Virtual Keys:** Navigate to the "Virtual Keys" page on [Portkey](https://app.portkey.ai/) and hit the "Add Key" button. Choose your AI provider and assign a unique name to your key. Your virtual key is ready!

---
### **Step 2️⃣ : Construct your LLM, add Portkey features, provider features, and prompt**

### 2️⃣: Construct your LLM, add Portkey features, provider features, and prompt
#### **Portkey Features**:
**Portkey Features**:
You can find a comprehensive [list of Portkey features here](#📔-list-of-portkey-features). This includes settings for caching, retries, metadata, and more.

#### **Provider Features**:
**Provider Features**:
Portkey is designed to be flexible. All the features you're familiar with from your LLM provider, like `top_p`, `top_k`, and `temperature`, can be used seamlessly. Check out the [complete list of provider features here](https://github.com/Portkey-AI/portkey-python-sdk/blob/af0814ebf4f1961b5dfed438918fe68b26ef5f1e/portkey/api_resources/utils.py#L137).

#### **Setting the Prompt Input**:
You can set the input in two ways:
- For models like Claude and GPT3, use `prompt` = `(str)`
- For models like GPT3.5 & GPT4, use `messages` = `[array]`
**Setting the Prompt Input**:
You can set the input in two ways. For models like Claude and GPT3, use `prompt` = `(str)`, and for models like GPT3.5 & GPT4, use `messages` = `[array]`.

Here's how you can combine everything:

Expand All @@ -77,19 +73,10 @@ temperature = 1
messages = [{"role": "user", "content": "Who are you?"}]

# Construct LLM
llm = LLMOptions(
provider=provider,
virtual_key=virtual_key,
trace_id=trace_id,
model=model,
temperature=temperature,
messages=messages
)
llm = LLMOptions(provider=provider, virtual_key=virtual_key, trace_id=trace_id, model=model, temperature=temperature, messages=messages)
```

---

### 3️⃣: Construct the Portkey Client
### **Steo 3️⃣ : Construct the Portkey Client**

Portkey client's config takes 3 params: `api_key`, `mode`, `llms`.

Expand All @@ -107,9 +94,7 @@ from portkey import Config
portkey.config = Config(mode="single",llms=[llm])
```

---

### 4️⃣: Let's Call the Portkey Client!
### **Step 4️⃣ : Let's Call the Portkey Client!**

The Portkey client can do `ChatCompletions` and `Completions`.

Expand All @@ -135,22 +120,18 @@ import portkey
from portkey import Config, LLMOptions

# Let's construct our LLMs.

llm1 = LLMOptions(provider="openai", model="gpt-4", virtual_key="key_a"),
llm2 = LLMOptions(provider="openai", model="gpt-3.5-turbo", virtual_key="key_a")

# Now let's construct the Portkey client where we will set the fallback logic

portkey.config = Config(mode="fallback",llms=[llm1,llm2])

# And, that's it!

response = portkey.ChatCompletions.create()

print(response.choices[0].message)
```

## **📔 List of Portkey Features**
## **📔 Full List of Portkey Config**

| Feature | Config Key | Value(Type) | Required |
|---------------------|-------------------------|--------------------------------------------------|-------------|
Expand Down

0 comments on commit f2fdac8

Please sign in to comment.