Closed oxaroky02 closed 3 months ago
I'm going to stop there for now. In general, I think it's great! Just some concerns about how the code is structured.
There are no tests, but I can contribute those afterwards. Archyve isn't near 100% test coverage yet, but there are 100-odd tests in there now, and I'm trying to test new code.
There are no tests, but I can contribute those afterwards. Archyve isn't near 100% test coverage yet, but there are 100-odd tests in there now, and I'm trying to test new code.
Yep. I did want to include tests but I ran into some trouble running the tests. I promise to start adding testing in separate PRs.
There are no tests, but I can contribute those afterwards. Archyve isn't near 100% test coverage yet, but there are 100-odd tests in there now, and I'm trying to test new code.
Yep. I did want to include tests but I ran into some trouble running the tests. I promise to start adding testing in separate PRs.
OK, figured out my problem with running tests; can run tests now, and found that the old ollama
chat test failed due to my refactoring. So I've fixed that so at least all the current tests pass again. Sorry about that.
TLDR;
The detailed description is organized as follows.
ModelServer
ModelConfig
ApiCall
Model changes
ModelServer
provider
enumeration, renamingopenai
toopenai_azure
and setting it up with a naming prefix so that we can query a model server withserver.provider_ollama?
andserver.provider_openai_azure?
.api_key
field for use with external servers that require API tokens.api_key_required?
andapi_version_required?
implemented based on a server's provider, both of which return true if the provider isopenai_azure
.api_key
.ModelConfig
api_version
and an optionalmodel_server
reference.api_version_required?
which calls the same method for a model server if presentapi_version
ApiCall
from_faraday
support method to create an API call record based on Faraday-middleware based request/responses.LLM Clients
Common
#chat
(in all clients) to receiveMessage
and handle the chat history conversion within the clientOpenAI Client
ruby-openai
gem to the project's bundleropenai/
client API as follows under theOpenai::
module as follows:Client
base class for non-Azure-specific use of theruby-openai
gem, including integration with Faraday'sinterceptor
middleware flow to track request/response detailschat_request
andcomplete_request
andembedding_request
methods into theClient
where they belong for clarityChatMessageHelper
to help processMessage
for chat history formatting for server-specific requestsAzureClient
implementation sub-class for all the Azure-specific aspects of the client.ruby-openai
"client" to avoid ambiguity with the use of "client" in Archyve.Ollama Client
#chat
to use the OpenAIChatMessageHelper
for the chat history, since Ollama API is compatible with OpenAI.Base Client
api_version
propertyclient_class_for
factory method to return appropriate client class based on the providerServices
Helpers
Helpers
moduleModelClientHelper
helper that is shared by various services, consolidating common functionality when instantiating an LLM client based on aModelConfig
.Common Client Support
ModelClientHelper
(update: replaced mixin with helper instances) for the common functionality to be able to retrieve an LLM client based on the model configuration:ResponseStreamer
,Embedder
andSummarizeMessage
Message
processing for chat history.TheIngestor
,ReplyToMessage
andSearch
services to reflect the changes in the refactored service classesAPI
ModelLoader
to support the model server's API keyTesting
ollama/chat_spec
to instead test the Open AIChatMessageHelper
shared by both clients#embed
,#chat
, and#complete
spec_helper.rb
config check to exclude tests tagged with:az_openai
unless bothAZURE_OPENAI_API_KEY
andAZURE_OPENAI_URI
env variables have been set.