Skip to content

Commit

Permalink
fix: resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitjavelin committed Feb 26, 2025
2 parents ee43e99 + 747de97 commit 4d8f2a3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/bedrock/bedrock_client_universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def init_bedrock():

# Initialize Javelin Client (if you want the route registered)
config = JavelinConfig(
javelin_api_key="YOUR_JAVELIN_API_KEY" # Replace with your Javelin API key
javelin_api_key=os.getenv("JAVELIN_API_KEY") # Replace with your Javelin API key
)
javelin_client = JavelinClient(config)

Expand Down
28 changes: 28 additions & 0 deletions javelin_sdk/chat_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def _build_request_data(
) -> Dict[str, Any]:
"""Build the request data for the API call"""
is_completions = route_type == "completions"
is_embeddings = route_type == "embeddings"
if is_embeddings:
return {
"type": route_type,
"input": messages_or_prompt,
**additional_kwargs,
}
request_data = {
"temperature": temperature,
**({"max_tokens": max_tokens} if max_tokens is not None else {}),
Expand Down Expand Up @@ -245,3 +252,24 @@ class Chat:

def __init__(self, client):
self.completions = ChatCompletions(client)


class Embeddings(BaseCompletions):
"""Main embeddings interface"""

def create(
self,
route: str,
input: str,
model: Optional[str] = None,
encoding_format: Optional[str] = None,
**kwargs,
) -> Dict[str, Any]:
"""Create a chat completion request"""
return self._create_request(
route,
input,
model=model,
encoding_format=encoding_format,
**kwargs,
)
3 changes: 2 additions & 1 deletion javelin_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from opentelemetry.semconv._incubating.attributes import gen_ai_attributes
from opentelemetry.trace import SpanKind, Status, StatusCode

from javelin_sdk.chat_completions import Chat, Completions
from javelin_sdk.chat_completions import Chat, Completions, Embeddings
from javelin_sdk.models import HttpMethod, JavelinConfig, Request
from javelin_sdk.services.gateway_service import GatewayService
from javelin_sdk.services.modelspec_service import ModelSpecService
Expand Down Expand Up @@ -89,6 +89,7 @@ def __init__(self, config: JavelinConfig) -> None:

self.chat = Chat(self)
self.completions = Completions(self)
self.embeddings = Embeddings(self)

self.tracer = configure_span_exporter()

Expand Down

0 comments on commit 4d8f2a3

Please sign in to comment.