Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttestbot[bot] committed Aug 27, 2024
1 parent e59471b commit 8634ccd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ async def embeddings_and_transcription_example():

embeddings = await client.get_embeddings(input_texts, TEXT_EMBEDDING_ADA_002)
transcription = await client.get_transcription("~/.mentat/logs/audio/talk_transcription.wav", WHISPER_1)

print(transcription.text)
print(f"{len(embeddings.embeddings)} embeddings fetched for ${(embeddings.cost or 0) / 100:.2f}")


async def run_all_examples():
Expand All @@ -172,5 +174,4 @@ async def run_all_examples():


if __name__ == "__main__":
asyncio.run(messages_example())
# asyncio.run(run_all_examples())
asyncio.run(run_all_examples())
6 changes: 3 additions & 3 deletions spice/call_args.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass, field
from typing import Any, AsyncIterator, Callable, Collection, Dict, Generic, List, Optional, TypeVar, cast
from dataclasses import dataclass
from typing import Collection, Optional

from openai.types.chat.completion_create_params import ResponseFormat

from spice.spice_message import MessagesEncoder, SpiceMessage
from spice.spice_message import SpiceMessage


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion spice/retry_strategy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, Callable, Generic, Optional, TypeVar
from typing import Generic, TypeVar

from spice.spice import SpiceCallArgs

Expand Down
2 changes: 1 addition & 1 deletion spice/retry_strategy/converter_strategy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dataclasses
from typing import Any, Callable, Optional
from typing import Any, Callable

from spice.retry_strategy import Behavior, RetryStrategy
from spice.spice import SpiceCallArgs
Expand Down
4 changes: 1 addition & 3 deletions spice/retry_strategy/default_strategy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import dataclasses
from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, Callable, Optional, TypeVar
from typing import Any, Callable, Optional

from spice.retry_strategy import Behavior, RetryStrategy, T
from spice.spice import SpiceCallArgs
Expand Down
2 changes: 1 addition & 1 deletion spice/retry_strategy/validator_strategy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dataclasses
from typing import Any, Callable, Optional, Tuple
from typing import Any, Callable, Tuple

from spice.call_args import SpiceCallArgs
from spice.retry_strategy import Behavior, RetryStrategy
Expand Down
4 changes: 3 additions & 1 deletion spice/wrapped_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def extract_text_and_tokens(self, chat_completion, call_args: SpiceCallArgs):
return TextAndTokens(
text=chat_completion.choices[0].message.content,
input_tokens=chat_completion.usage.prompt_tokens,
cache_creation_input_tokens=0,
cache_read_input_tokens=0,
output_tokens=chat_completion.usage.completion_tokens,
)

Expand Down Expand Up @@ -311,7 +313,7 @@ def _convert_messages(
if image.startswith("http"):
try:
response = httpx.get(image)
except:
except: # noqa: E722
raise ImageError(f"Error fetching image {image}.")

media_type = response.headers.get("content-type", mimetypes.guess_type(image)[0])
Expand Down

0 comments on commit 8634ccd

Please sign in to comment.