Spaces:
Running
Running
:recycle: [Refactor] Rename message_streamer to huggingface_streamer
Browse filesFiles changed (2)
18 unmodified lines19202122232425262762 unmodified lines9091929394959697989910010110210310410510610710818 unmodified linesfrom messagers.message_composer import MessageComposerfrom mocks.stream_chat_mocker import stream_chat_mockfrom networks.message_streamer import MessageStreamerfrom tclogger import loggerfrom constants.models import AVAILABLE_MODELS_DICTSclass ChatAPIApp:62 unmodified linesdef chat_completions(self, item: ChatCompletionsPostItem, api_key: str = Depends(extract_api_key)):streamer = MessageStreamer(model=item.model)composer = MessageComposer(model=item.model)composer.merge(messages=item.messages)# streamer.chat = stream_chat_mockstream_response = streamer.chat_response(prompt=composer.merged_str,temperature=item.temperature,top_p=item.top_p,max_new_tokens=item.max_tokens,api_key=api_key,use_cache=item.use_cache,)if item.stream:event_source_response = EventSourceResponse(streamer.chat_return_generator(stream_response),18 unmodified lines192021222324252662 unmodified lines899091929394959618 unmodified linesfrom messagers.message_composer import MessageComposerfrom mocks.stream_chat_mocker import stream_chat_mockfrom networks.huggingface_streamer import HuggingfaceStreamerfrom networks.openai_streamer import OpenaiStreamerclass ChatAPIApp:62 unmodified linesdef chat_completions(self, item: ChatCompletionsPostItem, api_key: str = Depends(extract_api_key)):streamer = HuggingfaceStreamer(model=item.model)composer = MessageComposer(model=item.model)if item.stream:event_source_response = EventSourceResponse(streamer.chat_return_generator(stream_response),
1 unmodified line234567892 unmodified lines12131415161718192021221 unmodified lineimport reimport requestsfrom tclogger import loggerfrom tiktoken import get_encoding as tiktoken_get_encodingfrom transformers import AutoTokenizerfrom constants.models import (2 unmodified linesTOKEN_LIMIT_MAP,TOKEN_RESERVED,)from constants.env import PROXIESfrom messagers.message_outputer import OpenaiStreamOutputerclass MessageStreamer:def __init__(self, model: str):if model in MODEL_MAP.keys():self.model = model1 unmodified line234567892 unmodified lines12131415161718192021221 unmodified lineimport reimport requestsfrom tclogger import loggerfrom transformers import AutoTokenizerfrom constants.models import (2 unmodified linesTOKEN_LIMIT_MAP,TOKEN_RESERVED,)from constants.envs import PROXIESfrom messagers.message_outputer import OpenaiStreamOutputerclass HuggingfaceStreamer:def __init__(self, model: str):if model in MODEL_MAP.keys():self.model = model
apis/chat_api.py+4-16
networks/message_streamer.py → networks/huggingface_streamer.pyRenamed+3-3