Skip to content

Commit

Permalink
Merge pull request #1118 from phidatahq/fix-fireworks-streaming-phi-1032
Browse files Browse the repository at this point in the history
fix-fireworks-streaming-phi-1032
  • Loading branch information
ashpreetbedi authored Sep 8, 2024
2 parents 94d17ae + c245986 commit dfb5c8e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion phi/llm/fireworks/fireworks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
from os import getenv
from typing import Optional
from typing import Optional, List, Iterator

from phi.llm.message import Message
from phi.llm.openai.like import OpenAILike
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk


class Fireworks(OpenAILike):
name: str = "Fireworks"
model: str = "accounts/fireworks/models/firefunction-v1"
api_key: Optional[str] = getenv("FIREWORKS_API_KEY")
base_url: str = "https://api.fireworks.ai/inference/v1"

def invoke_stream(self, messages: List[Message]) -> Iterator[ChatCompletionChunk]:
yield from self.get_client().chat.completions.create(
model=self.model,
messages=[m.to_dict() for m in messages], # type: ignore
stream=True,
**self.api_kwargs,
) # type: ignore

0 comments on commit dfb5c8e

Please sign in to comment.