Zenaight commited on
Commit
2dbed6d
·
verified ·
1 Parent(s): 7126d11

weird python update

Browse files
Files changed (1) hide show
  1. app/main.py +5 -5
app/main.py CHANGED
@@ -18,7 +18,7 @@ from pydantic import BaseModel
18
  # Import LangChain components
19
  from langchain_openai import ChatOpenAI
20
  from langchain.prompts import PromptTemplate
21
- from langchain.chains import LLMChain
22
 
23
  # Import the base LLM class to build our custom wrapper
24
  from langchain.llms.base import LLM
@@ -305,9 +305,9 @@ async def get_suggestions(
305
  input_variables=["prompt"],
306
  template=prompt
307
  )
308
- suggestion_chain = LLMChain(llm=llm, prompt=suggestion_prompt)
309
  # Run the chain without additional inputs, since prompt is fully baked
310
- raw_text = await asyncio.to_thread(suggestion_chain.run, {})
311
  # Strip out any leading numbers, bullets or whitespace
312
  suggestion_array = [
313
  re.sub(r'^\s*[\-\d\.\)\s]+', '', line).strip()
@@ -396,13 +396,13 @@ async def generate_business_plan(data: GenerateRequest):
396
  llm_selected.max_tokens = 6000 # Increase max tokens to ensure full completion
397
  logging.info(f"Increased max_tokens from {original_max_tokens} to {llm_selected.max_tokens}")
398
 
399
- plan_chain = LLMChain(llm=llm_selected, prompt=plan_prompt)
400
 
401
  logging.info(f"Generated prompt for business plan with model {data.model}")
402
 
403
  try:
404
  logging.info(f"Generating business plan with model: {data.model}")
405
- full_plan = await asyncio.to_thread(plan_chain.run, {"q_and_a": q_and_a, "business_context": business_context})
406
  logging.info(f"Successfully generated business plan with model: {data.model}")
407
 
408
  # Check if plan seems truncated
 
18
  # Import LangChain components
19
  from langchain_openai import ChatOpenAI
20
  from langchain.prompts import PromptTemplate
21
+ from langchain import RunnableSequence
22
 
23
  # Import the base LLM class to build our custom wrapper
24
  from langchain.llms.base import LLM
 
305
  input_variables=["prompt"],
306
  template=prompt
307
  )
308
+ suggestion_chain: RunnableSequence = suggestion_prompt | llm
309
  # Run the chain without additional inputs, since prompt is fully baked
310
+ raw_text = await asyncio.to_thread(suggestion_chain.invoke, {})
311
  # Strip out any leading numbers, bullets or whitespace
312
  suggestion_array = [
313
  re.sub(r'^\s*[\-\d\.\)\s]+', '', line).strip()
 
396
  llm_selected.max_tokens = 6000 # Increase max tokens to ensure full completion
397
  logging.info(f"Increased max_tokens from {original_max_tokens} to {llm_selected.max_tokens}")
398
 
399
+ plan_chain: RunnableSequence = plan_prompt | llm_selected
400
 
401
  logging.info(f"Generated prompt for business plan with model {data.model}")
402
 
403
  try:
404
  logging.info(f"Generating business plan with model: {data.model}")
405
+ full_plan = await asyncio.to_thread(plan_chain.invoke, {"q_and_a": q_and_a, "business_context": business_context})
406
  logging.info(f"Successfully generated business plan with model: {data.model}")
407
 
408
  # Check if plan seems truncated