Skip to content

Commit

Permalink
XAI example.
Browse files Browse the repository at this point in the history
  • Loading branch information
MadcowD committed Oct 12, 2024
1 parent 0ecd0b8 commit ed6f21a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/providers/xai_ex.py
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

0 comments on commit ed6f21a

Please sign in to comment.