Spaces:
Sleeping
Sleeping
✅ mock ollama CI/CD and Dockerfile for deployment in hugging face
Browse files
src/marketingCampaignGen/components/model/generator.py
CHANGED
@@ -36,24 +36,41 @@ Write the campaign in the specified tone and make it persuasive.
|
|
36 |
|
37 |
self.chain = LLMChain(llm=self.llm, prompt=self.template)
|
38 |
|
39 |
-
def generate(self, input_data: dict) -> str:
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
36 |
|
37 |
self.chain = LLMChain(llm=self.llm, prompt=self.template)
|
38 |
|
39 |
+
# def generate(self, input_data: dict) -> str:
|
40 |
+
# feature_query = ", ".join(input_data["features"])
|
41 |
+
# examples = get_similar_examples(feature_query, top_k=2)
|
42 |
+
|
43 |
+
# # Flatten list of documents
|
44 |
+
# flat_examples = [doc for sublist in examples["documents"] for doc in sublist]
|
45 |
+
# example_text = "\n\n".join(flat_examples) if flat_examples else "None"
|
46 |
+
|
47 |
+
# response = self.chain.invoke(...).run(
|
48 |
+
# product_name=input_data["product_name"],
|
49 |
+
# features=feature_query,
|
50 |
+
# brand=input_data["brand"],
|
51 |
+
# audience=input_data["audience"],
|
52 |
+
# tone=input_data["tone"],
|
53 |
+
# goal=input_data["goal"],
|
54 |
+
# # examples=example_text
|
55 |
+
# )
|
56 |
+
|
57 |
+
# return response
|
58 |
+
# Adjust path below to the exact module & class where .invoke() is called
|
59 |
+
@patch("src.marketingCampaignGen.components.model.generator.Ollama.invoke")
|
60 |
+
def test_generate_campaign(mock_invoke):
|
61 |
+
mock_invoke.return_value = "Mocked marketing campaign."
|
62 |
+
|
63 |
+
response = client.post("/generate", json=sample_payload)
|
64 |
+
|
65 |
+
print("\n[DEBUG] Status Code:", response.status_code)
|
66 |
+
try:
|
67 |
+
print("[DEBUG] Response JSON:", response.json())
|
68 |
+
except Exception as e:
|
69 |
+
print("[DEBUG] Response could not be parsed:", e)
|
70 |
+
print("[DEBUG] Raw Response Text:", response.text)
|
71 |
+
|
72 |
+
assert response.status_code == 200
|
73 |
+
assert "campaign" in response.json()
|
74 |
+
assert isinstance(response.json()["campaign"], str)
|
75 |
+
assert len(response.json()["campaign"]) > 10
|
76 |
|