forked from phoenix/litellm-mirror
Update main.py
This commit is contained in:
parent
1017663d84
commit
3bed01f5c1
1 changed files with 26 additions and 0 deletions
|
@ -34,6 +34,32 @@ def completion(model, messages, azure=False):
|
||||||
engine=model,
|
engine=model,
|
||||||
messages = messages
|
messages = messages
|
||||||
)
|
)
|
||||||
|
elif "replicate" in model:
|
||||||
|
prompt = " ".join([message["content"] for message in messages])
|
||||||
|
output = replicate.run(
|
||||||
|
model,
|
||||||
|
input={
|
||||||
|
"prompt": prompt,
|
||||||
|
})
|
||||||
|
print(f"output: {output}")
|
||||||
|
response = ""
|
||||||
|
for item in output:
|
||||||
|
print(f"item: {item}")
|
||||||
|
response += item
|
||||||
|
new_response = {
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"finish_reason": "stop",
|
||||||
|
"index": 0,
|
||||||
|
"message": {
|
||||||
|
"content": response,
|
||||||
|
"role": "assistant"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
print(f"new response: {new_response}")
|
||||||
|
response = new_response
|
||||||
elif model in cohere_models:
|
elif model in cohere_models:
|
||||||
cohere_key = os.environ.get("COHERE_API_KEY")
|
cohere_key = os.environ.get("COHERE_API_KEY")
|
||||||
co = cohere.Client(cohere_key)
|
co = cohere.Client(cohere_key)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue