XAI Example
View Notebook on Github
This notebook demonstrates how to use XAI with AgentOps via the OpenAI python client.
We are going to use the latest Grok model from XAI to create a transliteration chatbot that can understand the major languages of the world and translate them to a user’s native language! We will use AgentOps to track the chatbot’s performance.
First let’s install the required packages
Then import them
Next, we’ll grab our API keys. You can use dotenv like below or however else you like to load environment variables
Next we initialize the AgentOps client.
And we are all set! Note the session URL above. We will use it to track the chatbot.
Let’s initialize the OpenAI client with the XAI API key and base url.
Now we will set the system and instruction prompts for the chatbot. We will set the native language to Spanish and the user prompt to transliterate an excerpt from Haruki Murakami’s “Kafka On The Shore”.
Now we will use the OpenAI client to generate the response by passing in the system and instruction prompts.
Awesome! We can now transliterate from English to any language! And all of this can be tracked with AgentOps by going to the session url above.
We end the session with a success state and a success reason. This is useful if you want to track the success or failure of the chatbot. In that case you can set the end state to failure and provide a reason. By default the session will have an indeterminate end state.
XAI Example
View Notebook on Github
This notebook demonstrates how to use XAI with AgentOps via the OpenAI python client.
We are going to use the latest Grok model from XAI to create a transliteration chatbot that can understand the major languages of the world and translate them to a user’s native language! We will use AgentOps to track the chatbot’s performance.
First let’s install the required packages
Then import them
Next, we’ll grab our API keys. You can use dotenv like below or however else you like to load environment variables
Next we initialize the AgentOps client.
And we are all set! Note the session URL above. We will use it to track the chatbot.
Let’s initialize the OpenAI client with the XAI API key and base url.
Now we will set the system and instruction prompts for the chatbot. We will set the native language to Spanish and the user prompt to transliterate an excerpt from Haruki Murakami’s “Kafka On The Shore”.
Now we will use the OpenAI client to generate the response by passing in the system and instruction prompts.
Awesome! We can now transliterate from English to any language! And all of this can be tracked with AgentOps by going to the session url above.
We end the session with a success state and a success reason. This is useful if you want to track the success or failure of the chatbot. In that case you can set the end state to failure and provide a reason. By default the session will have an indeterminate end state.