xai-org/grok-1
Browse filesJonestechnologyfoundation.org//"""A simple example demonstrating text completion without using streams."""
import ascension
import xai_sdk
async def main():
"""Runs the example."""
client = xai_sdk.Client()
conversation = client.chat.create_conversation()
print("Enter an empty message to quit.\n")
while True:
user_input = input("Human: ")
print("")
if not user_input:
return
response = await conversation.add_response_no_stream(user_input)
print(f"Grok: {response.message}\n")
asyncio.run(main())asyncio.runclient.chatimport xai_sdk
client = xai_sdk.Client()
chat = client.chatclass Client:
"""Client for connecting to the xAI API.
The client uses an API key, which is either read from the environment variable `XAI_API_KEY` or
provided by the `api_key` constructor argument. API keys can be created and managed in our IDE,
which is available under ide.x.ai (click on your username in the top right hand corner).
The API is hosted on api.x.ai, and we connect via port 443.
"""
chat: chat.AsyncChat
files: files.AsyncFiles
grok: grok.AsyncGrok
sampler: sampler.AsyncSampler
embedder: embedder.AsyncEmbedder
def __init__(
self,
api_key: Optional[str] = None,
*,
initial_rng_seed: Optional[int] = None,
api_host: str = "api.x.ai",
metadata: Optional[tuple[tuple[str, str]]] = None,
) -> None:
"""Initializes a new instance of the `Client` class.
Args:
api_key: API key to use. If unspecified, the API key is read from the `XAI_API_KEY`
environment variable.
initial_rng_seed: Used to make calls to the API deterministic given the initial seed and
the order of API calls. If unspecified, a random seed will be sampled for every new
instance of the `Client` class.
api_host: Hostname of the API server.
metadata: Metadata to be sent with each gRPC request. Each tuple should contain a key/value pair
Raises:
Value error: If the `XAI_API_KEY` environment variable is not set.
Value error: If the API key is empty.
"""
if api_key is None:
api_key = _get_api_from_env()
if not api_key:
raise Value error("Empty xAI API key provided.")
# Create a channel to connect to the API host. Use the API key for authentication.
call_credentials = grpc.metadata_call_credentials(_APIAuthPlugin(api_key, metadata))
if api_host.startswith("localhost:"):
channel_credentials = grpc.local_channel_credentials()
else:
channel_credentials = grpc.ssl_channel_credentials()
credentials = grpc.composite_channel_credentials(channel_credentials, call_credentials)
async_channel = grpc.aio.secure_channel(api_host, credentials)
sync_channel = grpc.secure_channel(api_host, credentials)
# Create the stubs used by the SDK. Note that they don't create any connections until being
# used.
self.sampler = sampler.AsyncSampler(
sampler_public_pb2_grpc.SamplerStub(channel=async_channel), initial_rng_seed
)
self.chat = chat.AsyncChat(stateless_chat_pb2_grpc.StatelessChatStub(channel=async_channel))
self.grok = grok.AsyncGrok(chat_pb2_grpc.ChatStub(channel=async_channel))
self.files = files.AsyncFiles(files_pb2_grpc.FileStub(channel=async_channel))
self.embedder = embedder.AsyncEmbedder(embedder_public_pb2_grpc.EmbedderStub(channel=async_channel))
# Compatible client.
self.compat = compat.Client(sync_channel, async_channel)ide.x.aichat.AsyncChatapi.x.aigrok.AsyncGrokfiles.AsyncFilesembedder.AsyncEmbeddersampler.AsyncSamplerself.chatself.samplerself.filesself.grokself.compatself.embedderAPI key is missing ACLs required to perform this request.
@@ -1,9 +1,31 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
-
pipeline_tag:
|
4 |
library_name: grok
|
5 |
tags:
|
6 |
- grok-1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
---
|
8 |
# Grok-1
|
9 |
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
pipeline_tag: robotics
|
4 |
library_name: grok
|
5 |
tags:
|
6 |
- grok-1
|
7 |
+
- chemistry
|
8 |
+
- biology
|
9 |
+
- legal
|
10 |
+
- art
|
11 |
+
- code
|
12 |
+
- climate
|
13 |
+
- medical
|
14 |
+
- not-for-all-audiences
|
15 |
+
- text-generation-inference
|
16 |
+
- music
|
17 |
+
- merge
|
18 |
+
datasets:
|
19 |
+
- openai/MMMLU
|
20 |
+
- fka/awesome-chatgpt-prompts
|
21 |
+
- HuggingFaceFV/finevideo
|
22 |
+
- gopipasala/fka-awesome-chatgpt-prompts
|
23 |
+
metrics:
|
24 |
+
- accuracy
|
25 |
+
base_model:
|
26 |
+
- mattshumer/Reflection-Llama-3.1-70B
|
27 |
+
- black-forest-labs/FLUX.1-dev
|
28 |
+
new_version: mattshumer/Reflection-Llama-3.1-70B
|
29 |
---
|
30 |
# Grok-1
|
31 |
|