Hi everyone! I'm trying to learn how these LLM apps work under the hood. I see LangChain everywhere, but all the abstractions (chains, agents, loaders) feel a bit overwhelming for a beginner like me.
I wanted to see if I could build a basic FAQ bot using AWS and OpenAI directly, without the full LangChain library. My goal was just to match a user question against some FAQ entries and return the best answer. Here's my simple Python script:
```python
import openai
import json
faqs = [
{"q": "What is your return policy?", "a": "30 days with receipt."},
{"q": "Do you ship internationally?", "a": "Yes, to over 50 countries."}
]
def find_best_answer(user_query):
prompt = f"""
User question: {user_query}
FAQ List: {json.dumps(faqs)}
Return ONLY the matching FAQ answer if found, or 'Sorry, I don't know.'.
"""
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": prompt}],
temperature=0
)
return response.choices[0].message.content
# Example usage
print(find_best_answer("Can I return something?"))
```
It works! But I have questions:
- Is this a bad way to do it? Should I be using embeddings for similarity instead?
- How would I make this scale? My FAQ list is tiny now.
- For a real project, is skipping LangChain a mistake, or is it good to learn the basics first?
I'm thinking of putting this behind an AWS Lambda with API Gateway next. Any tips or pitfalls?