-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ell | ||
import openai | ||
import os | ||
|
||
ell.init(verbose=True) | ||
|
||
# Models are automatically registered, so we can use them without specifying the client | ||
@ell.simple(model='grok-2-mini') | ||
def use_default_xai_client(prompt: str) -> str: | ||
return prompt | ||
|
||
print(use_default_xai_client("Tell me a joke, Grok!")) | ||
|
||
|
||
# If you want to use a custom client you can. | ||
# Custom client for X.AI | ||
xai_client = openai.Client(base_url="https://api.x.ai/v1", api_key=your_api_key) | ||
|
||
@ell.simple(model='grok-2', client=xai_client) | ||
def chat_xai(prompt: str) -> str: | ||
return prompt |