octo-patch commented on code in PR #1523:
URL: https://github.com/apache/hamilton/pull/1523#discussion_r3005723049


##########
contrib/hamilton/contrib/dagworks/conversational_rag/__init__.py:
##########
@@ -112,13 +130,31 @@ def answer_prompt(context: str, standalone_question: str) 
-> str:
     return template.format(context=context, question=standalone_question)
 
 
-def llm_client() -> openai.OpenAI:
-    """The LLM client to use for the RAG model."""
[email protected]_not(provider="minimax")
+def llm_client__openai() -> openai.OpenAI:
+    """The OpenAI LLM client (default).
+
+    Uses the OPENAI_API_KEY environment variable for authentication.
+    """
     return openai.OpenAI()
 
 
-def conversational_rag_response(answer_prompt: str, llm_client: openai.OpenAI) 
-> str:
-    """Creates the RAG response from the LLM model for the given prompt.
[email protected](provider="minimax")
+def llm_client__minimax() -> openai.OpenAI:
+    """The MiniMax LLM client via OpenAI-compatible API.
+
+    Uses the MINIMAX_API_KEY environment variable for authentication.
+    MiniMax provides an OpenAI-compatible endpoint at 
https://api.minimax.io/v1.
+    """
+    return openai.OpenAI(
+        base_url="https://api.minimax.io/v1";,
+        api_key=os.environ.get("MINIMAX_API_KEY"),
+    )
+
+
[email protected]_not(provider="minimax")
+def conversational_rag_response__openai(answer_prompt: str, llm_client: 
openai.OpenAI) -> str:

Review Comment:
   Good point! I've refactored both files to extract `model` as a config-driven 
input. Now `llm_client` and `model` each have `__openai` / `__minimax` config 
variants, while `standalone_question`, `conversational_rag_response`, and 
`rag_response` are single shared functions that accept `model` as a parameter. 
This eliminates the duplication entirely.



##########
contrib/hamilton/contrib/dagworks/faiss_rag/__init__.py:
##########
@@ -94,11 +114,29 @@ def rag_response(rag_prompt: str, llm_client: 
openai.OpenAI) -> str:
     return response.choices[0].message.content
 
 
[email protected](provider="minimax")
+def rag_response__minimax(rag_prompt: str, llm_client: openai.OpenAI) -> str:
+    """Creates the RAG response using MiniMax M2.7.
+
+    MiniMax M2.7 is a high-performance model with 1M token context window.
+
+    :param rag_prompt: the prompt to send to the LLM.
+    :param llm_client: the LLM client to use.
+    :return: the response from the LLM.
+    """
+    response = llm_client.chat.completions.create(
+        model="MiniMax-M2.7",

Review Comment:
   Done! Extracted `model` as an input parameter with config variants. 
`rag_response` is now a single function that takes `model: str`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to