Llm
LLM
A class for running a Language Model Chain.
Source code in write_the/llm.py
__init__(prompt, temperature=0, model_name='gpt-3.5-turbo-instruct')
Initializes the LLM class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt |
PromptTemplate
|
The prompt template to use. |
required |
temperature |
int
|
The temperature to use for the model. Defaults to 0. |
0
|
model_name |
str
|
The name of the model to use. Defaults to "gpt-3.5-turbo-instruct". |
'gpt-3.5-turbo-instruct'
|
Side Effects
Sets the class attributes.
Raises:
Type | Description |
---|---|
KeyError
|
If the model_name is not found in the models dictionary. |
Source code in write_the/llm.py
number_of_tokens(text)
Counts the number of tokens in a given text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to count tokens for. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
The number of tokens in the text. |
Source code in write_the/llm.py
run(code, **kwargs)
async
Runs the Language Model Chain asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code |
str
|
The code to use for the chain. |
required |
**kwargs |
dict
|
Additional keyword arguments. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
str |
The generated text. |