#context-aware
Explore tagged Tumblr posts
Link
0 notes
Text
Introduction to the LangChain Framework

LangChain is an open-source framework designed to simplify and enhance the development of applications powered by large language models (LLMs). By combining prompt engineering, chaining processes, and integrations with external systems, LangChain enables developers to build applications with powerful reasoning and contextual capabilities. This tutorial introduces the core components of LangChain, highlights its strengths, and provides practical steps to build your first LangChain-powered application.
What is LangChain?
LangChain is a framework that lets you connect LLMs like OpenAI's GPT models with external tools, data sources, and complex workflows. It focuses on enabling three key capabilities: - Chaining: Create sequences of operations or prompts for more complex interactions. - Memory: Maintain contextual memory for multi-turn conversations or iterative tasks. - Tool Integration: Connect LLMs with APIs, databases, or custom functions. LangChain is modular, meaning you can use specific components as needed or combine them into a cohesive application.
Getting Started
Installation First, install the LangChain package using pip: pip install langchain Additionally, you'll need to install an LLM provider (e.g., OpenAI or Hugging Face) and any tools you plan to integrate: pip install openai
Core Concepts in LangChain
1. Chains Chains are sequences of steps that process inputs and outputs through the LLM or other components. Examples include: - Sequential chains: A linear series of tasks. - Conditional chains: Tasks that branch based on conditions. 2. Memory LangChain offers memory modules for maintaining context across multiple interactions. This is particularly useful for chatbots and conversational agents. 3. Tools and Plugins LangChain supports integrations with APIs, databases, and custom Python functions, enabling LLMs to interact with external systems. 4. Agents Agents dynamically decide which tool or chain to use based on the user’s input. They are ideal for multi-tool workflows or flexible decision-making.
Building Your First LangChain Application
In this section, we’ll build a LangChain app that integrates OpenAI’s GPT API, processes user queries, and retrieves data from an external source. Step 1: Setup and Configuration Before diving in, configure your OpenAI API key: import os from langchain.llms import OpenAI # Set API Key os.environ = "your-openai-api-key" # Initialize LLM llm = OpenAI(model_name="text-davinci-003") Step 2: Simple Chain Create a simple chain that takes user input, processes it through the LLM, and returns a result. from langchain.prompts import PromptTemplate from langchain.chains import LLMChain # Define a prompt template = PromptTemplate( input_variables=, template="Explain {topic} in simple terms." ) # Create a chain simple_chain = LLMChain(llm=llm, prompt=template) # Run the chain response = simple_chain.run("Quantum computing") print(response) Step 3: Adding Memory To make the application context-aware, we add memory. LangChain supports several memory types, such as conversational memory and buffer memory. from langchain.chains import ConversationChain from langchain.memory import ConversationBufferMemory # Add memory to the chain memory = ConversationBufferMemory() conversation = ConversationChain(llm=llm, memory=memory) # Simulate a conversation print(conversation.run("What is LangChain?")) print(conversation.run("Can it remember what we talked about?")) Step 4: Integrating Tools LangChain can integrate with APIs or custom tools. Here’s an example of creating a tool for retrieving Wikipedia summaries. from langchain.tools import Tool # Define a custom tool def wikipedia_summary(query: str): import wikipedia return wikipedia.summary(query, sentences=2) # Register the tool wiki_tool = Tool(name="Wikipedia", func=wikipedia_summary, description="Retrieve summaries from Wikipedia.") # Test the tool print(wiki_tool.run("LangChain")) Step 5: Using Agents Agents allow dynamic decision-making in workflows. Let’s create an agent that decides whether to fetch information or explain a topic. from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType # Define tools tools = # Initialize agent agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) # Query the agent response = agent.run("Tell me about LangChain using Wikipedia.") print(response) Advanced Topics 1. Connecting with Databases LangChain can integrate with databases like PostgreSQL or MongoDB to fetch data dynamically during interactions. 2. Extending Functionality Use LangChain to create custom logic, such as summarizing large documents, generating reports, or automating tasks. 3. Deployment LangChain applications can be deployed as web apps using frameworks like Flask or FastAPI. Use Cases - Conversational Agents: Develop context-aware chatbots for customer support or virtual assistance. - Knowledge Retrieval: Combine LLMs with external data sources for research and learning tools. - Process Automation: Automate repetitive tasks by chaining workflows. Conclusion LangChain provides a robust and modular framework for building applications with large language models. Its focus on chaining, memory, and integrations makes it ideal for creating sophisticated, interactive applications. This tutorial covered the basics, but LangChain’s potential is vast. Explore the official LangChain documentation for deeper insights and advanced capabilities. Happy coding! Read the full article
#AIFramework#AI-poweredapplications#automation#context-aware#dataintegration#dynamicapplications#LangChain#largelanguagemodels#LLMs#MachineLearning#ML#NaturalLanguageProcessing#NLP#workflowautomation
0 notes
Text

even dogs pass the mirror test
#hello again everyone. how's it going#isat loop#in stars and time#isat fanart#in stars and time fanart#isat#lucabyteart#isat spoilers#so. had this idea Before getting my hands on the artbook and being validated. literally have a voice note from 4:30am on the 8th where#i frantically noted down this just horrid horrid horrid caption because i'd been musing on the sasasap Dress line all day i suppose#just kind of rotating in my brain the way any kind of first time trying on new clothes for them would be .#just absolutely mental breakdown material and not one i think would be recovered from quickly. they hate being in their own skin#like. a lot? like a lot. the collateral of any kind of transfemme read was barely in my mind until it ended up relevant again while i was#actively working on this. because christ that's a bad combo. 2x different forms of body dysphoria in one. maybe even 3x somehow#plus any scenario where they get clothes is... likely gifted. something they react viciously negatively to in game and i doubt#would improve thereafter. just a veritable katamari of disgust and self-loathing#like i was mostly just thinking abt how a lot of our collective depictions of loop being alienated from their body are rather abstract#in a body horror way mostly. on account of loop being more of a metaphor than a person half the time. so i think i wanted to depict#something closer to just. a human level of body dysphoria. no focus on the whole duplicate thing just... raw disgust for the self#but with the addition of recent discussion and playing ball more with the she/her loop and transfem loop angle...#scenario of leaning into femininity to try throw off suspicion on who they are PLUS realising they might want that PLUS the party#trying to use this to bond with them PLUS body dysphoria PLUS new!gender dysphoria PLUS the usual revulsion for wanting and desire#like. that is a catastrophic combination . not coming out of that one without it getting worse for a few weeks thereafter#that's a real lash out at everyone around them and then recede in shame type breakdown. which im sure looks interesting from#the party's pov because jesus christ that touched a nerve something awful (<- they only have half the context AT BEST)#. so . there's your free scenario to ponder on if you'd want to. seeing as ive done a picture without a shitload of words on it for once#ALSO don't get smart with me in the tags about the mirror test being an absolutely ass test in most regards re: self-awareness#or that things like minnows pass it. i'm a fellow pedant dont worry. it's just that minnow doesn't really have the same ring as dog yknow?#this is supposed to be like an absolutely excruciatingly self loathing thought spoken aloud of a caption. it's pithy and cruel on purpose#and more than a little inspired by (reblogged yesterday) liminal space's 'there is no other dog. it's just you'
1K notes
·
View notes
Text

Caption from Robin #101
Why yes, Tim Drake, I will call you a spoiled, squeamish , bourgie white boy actually.
#my exact opinion of him actually xD#he’s becoming self aware!#for context he refused to take food from a poor person#in the middle of the fallout of an apocalyptic earthquake too#jesus fucking Christ Tim#get some perspective#dc robin#robin#robin 1993#tim drake#bat family#dc comics
589 notes
·
View notes
Text
this whole idea in both the fandom and the games themselves that being a people attached to their past & a lost civilization is a failing whereas a celebration of the present is something to strive for wrt elven & dwarven culture is something that reads as fundamentally western & liberal to me.
#‘progress’ as inherently good and the past as inherently ‘backward’ and the idea that if ur looking back u can’t see forwards#<- the idea that these statements are Real and True facts of existence is deeply embedded in the western consciousness#these are legacies of the enlightment that have left their mark in allllllllll of our discourse#they are not necessarily true though. and i do think it’s good to be aware of what’s going on there!#i don’t think people quite realize the implications of what they’re doing when they project these ‘truths’ onto cultures#based on Real Groups (indigenous & jewish) whose persecution has ALSO been fueled by these ideas#there is an idea of a ‘good jew’ or a ‘good native’ that accepts the status quo and relinquishes ties to their peoples’ cultural pasts#and it’s a little troubling how much the fandom at large recreates this rhetoric even if this is a fictional context!#bioware critical#veilguard critical#<- implicitly ig
1K notes
·
View notes
Text
diving back into msscribe lore made me remember this; imo one of the funniest things about the My Immortal fanfic is the context to which it was born in the HP fandom at the time. In the early 2000's, HP fandom was a veritable arms race of who could write 'the best' most 'sophisticated' HP fanfic and the BNFs (Cassandra Clare, for example) were elevated to their pedestals because they were seen as the most talented fic writers. There were pissing contests, passive-aggressive comments about so-and-so being 'a mediocre fic writer' just shared between supposed 'friends', like one's popularity currency absolutely depended on whether or not the fandom deemed one's writing 'good enough'. Everyone was trying to be the goddamn idk Jane Austen of HP fandom pretty much. Even by 2006 (and msscribe's fall from grace, if you even care lol) this was still more or less the case- so the fact that this absolute unrepentantly bad HP fanfic came out during that time, the fact that Tara just kept posting chapters and doubling-down on people's criticisms and abject horror, the fact that this fanfic gave NO FUCKS about spelling, grammar, keeping characters intact, or even the original context of HP at all makes My Immortal's existence so much funnier than it already is on its lonesome. My Immortal was a slap in the fucking face to the entire established system and it reveled in being so.
Tellingly, I think, most people online today aren't going to know those 'popular', supremely 'well-written' fics off the top of their head, but even some IRL people I've talked with know and love My Immortal. Hell, Tom Felton has read it for his IG! Amy Lee either read or reacted to it a few of years back! It has it's own wikipedia, countless illustrations, works inspired by it and a cult following even today! I can't say the same for any of those fanfics that came before!
Whether My Immortal was a skilled troll or an unapologetic teenage girl that was going to write whatever the hell she wanted to, goddamn it, doesn't really matter because the effect was the same. Maybe remember that the next time you're agonizing over whether or not your writing is 'good enough'. Sometimes, it doesn't even need to be.
#my immortal#msscribe#one of my personal interests in fandom and internet history so i just had to share my thoughts#esp if there are people not aware of this context bc it makes everything so so much funnier
3K notes
·
View notes
Text

Oh my poor little Jace, papa wasn't joking.
#jace herondale#valentine morgenstern#sebastian morgenstern#jonathan morgenstern#jace morgenstern#jace lightwood#jace wayland#the shadowhunter chronicles#tsc#son of dawn#ghosts of the shadow market#the mortal instruments#tmi#izzy lightwood#city of bones#gotta agree with izzy on this one#being aware of the context
456 notes
·
View notes
Text
The Ghoul: Ain’t ya tired of bein’ nice? Don’t ya wanna go ape shit?
Lucy, going ape shit mind you: No! I’m tired of everyone being so mean all the god dang time!
#like she becomes more aware and wise but she’s still nice and doesn’t want to be cruel#and that is important that Lucy will not be victim to to the cruelty of the waste#kindness is a currency that no one values until someone tries to buy something with it#and i like that the ghoul thinks she’s adapting the way he did for a moment only for her to still do things a nice way#nice for the context of the wasteland atleast#fallout#fallout spoilers#fallout tv show#fallout show#cooper howard#the ghoul fallout#lucy maclean
2K notes
·
View notes
Note
theory, (or stating the obvious?) the reason Leo’s shell is now a gardening project is his real one was horrifically damaged and needed a full makeover to not die. Hooray for Fay magic!
Bonus points if my wild more speculative guess of Leo having memory loss (not including JJ trivia) including the invasion and his family to some extent being on the money, lol.
full marks on the theory~ but alas, no bonus points or extra credit this time...
leo very much remembers the invasion and the events leading up to his displacement to the feywilds. and he is very much aware of the absence of his brothers.
[ ⚘ clover crown ⚘ ]
#rottmnt#rottmnt fanart#tmnt 2018#clover crown#rottmnt leo#rottmnt au#rottmnt comic#save rottmnt#rise of the tmnt#rise of the teenage mutant ninja turtles#rottmnt oc#fidgetwing#rise leo#asks#leo is working... very very hard to try to figure out a way back home#im aware that you totttallyyyy asked this question like way earlier on in the au and before i gave more info abt the story#but im answering urs anyway bc it suits the comic i wanted to post and provides/reintroduces general context#which is useful bc its been a hOT second since ive posted this lmao. and also lends v well to helping explain the background to this scene~#so like! let the record show! fULL MARKS... THIS WAS THEORIZED BEFORE I CONFIRMED THIS STUFF LOL...
403 notes
·
View notes
Text
Generally I try to not be bothered by minor historical inaccuracies in KCD fic bc like, who cares! But one that has really stuck out a few times is the hard truth that; Henry of Skalitz has never and will never eat a potato.
It’s a tragedy, I know. This man would love potatoes. But he doesn’t even know they exist 😢
#Henry of Skalitz#context if you aren’t aware: potatoes are a new world crop - they’re indigenous to South America#KCD is set pre-Columbus so the Colombian exchange hasn’t started yet and no one in Europe will be growing potatoes for about another 100 yrs#at LEAST!!#kingdom come deliverance#kcd#kcd2#kingdom come deliverance 2#I try and leave my medieval historian brain at the door bc most things either don’t matter; are kind of vague anyway; work in thenarrative;#or accuracy would be more boring.#there’s a few that bother me mostly relating to modern vernacular and modern concepts of sexuality (same sex attraction is an aberration of#behaviour rather than identity and X-sexual are not words that will exist for a very long time and sodomy means non-baby making sex)#but those don’t have the same ‘No he doesn’t!!’ reaction from me as ‘Henry ate a potato’ 😅
258 notes
·
View notes
Text
I had a debate with my coworker about the Jedi not being crib robbers, regardless of the outcome of our argument, it has got me feeling ill about the parents who gave their children to the Jedi before or even during the Clone Wars. I'm watching Rebels and Kanan sounds so sad when he says he didn't know his parents. And then replaying Survivor, Cal has a conversation with Mosey about parents, and I remember that Cal is from Coruscant.
Like, imagine you're a parent. You probably live in the more poverty stricken levels of Coruscant. It's only a few years before the Clone Wars, but there's no way you could know that. All you know is that you have a baby in your arms, and there's Jedi in your home telling you that your baby is gifted, and that if you are willing, you can give your child up to a higher purpose. You'll probably never see your baby again, never see him grow, but... he'll grow up on the surface of Coruscant, in the Jedi Temple. He will not suffer poverty like you and your family, he will grow up to understand the mysteries of the Force and he'll become a peacekeeper of the galaxy and for whatever reason known only to you... it seems worth it.
You give your baby up.
And you wonder about him. Visiting the upper levels, you do the math in your head of how old he must be, and then you look out into the crowd made of trillions and wonder if you'll ever see a shock of red hair.
You never do, but that's fine. Your son is a Jedi, and maybe that's enough for you.
But then the Clone Wars come. And, not only do you see the Jedi join and lead their side of the war, but you begin to see the adult Jedi bring their young children with them on to the battle field.
Do you feel nothing? Do you feel anger? Acceptance? Do you think your baby is a hero? Do you go to the protests?
You watch the news, and perhaps you feel sick wondering if your baby will ever show up as a corpse.
But you never see him. And you're not sure if that's fine.
Years pass. The Jedi are branded traitors.
You hear about the masses of deaths, even the children are not spared from being branded as traitors and marked for execution from your new Emperor. Your baby is 12, or perhaps, was twelve. Perhaps 12 is the oldest he got, if he's lucky. That sticks with you.
You carry on.
Maybe you make a life for yourself within the Empire. Maybe you suppress the grief you must feel for the baby you gave to the Jedi all those years ago. Maybe you wallow in it. Maybe, on dark nights, surrounded by the never ending sounds of Coruscant, you think back to those simpler days, when there was no war, and you held your baby for the last time, and you think about what if. What if you held him tighter, and told the Jedi to leave. What if you worked harder to give him a better life yourself. What if you watched him grow, and he wasn't made a soldier, and he didn't die before he could become a teenager.
What if.
Years pass. You continue.
There's rumors of rebellion. You have your opinions on the Empire, on the rebels, some are deeply buried secrets, a bias you cannot escape, no one can know but that connection to the Jedi lingers.
Years pass. About a decade.
And you walk out one day, and you stop in your tracks, because you did not expect to see anything continue from your grief, the end of his story you told yourself.
A billboard shines in the darkness of the Coruscant lower levels, which isn't new, but this billboard stares at you.
A head full of red hair. Eyes that remind you of your partner. Scars scratch his features but his cheek bones remind you of your father.
Jedi terrorist.
About 22 years old.
Wanted by the Empire, and you don't know what to think but you know exactly what you're feeling.
And time moves on, and you're not in his life, but he's alive. Fighting against the Empire, while you continue to exist under the ruins of the Jedi Temple you gave him to, glancing up every once in a while, to see his face staring back in the light of wanted posters.
#ugh#UGHH#this isnt pro jedi or anti jedi#im just UGH UGHHHHH#Cal has wanted posters on the planet he's from and im SICK IM SICK IM SICK#star wars#long post#cal kestis#is this fanfiction????? i dont know but its driving me insane anyway#Jin rambles#star wars i NEED more context on the parents who give their children to the Jedi pre Clone Wars#cuz it drives me mad it drives me a little silly and a little goofy#imagine the pain those parents went through seeing the temple be invaded and the younglings inside be killed#imagine seeing a familiar face leading an army when you thought they'd be peacekeepers#imagine the pain#i wonder if any tried to demand access to the temple and to get their now 6 year olds back#i wonder#if they tried#if the children were even aware their parents wanted them back#were they even ALLOWED to want them back#im just thinking about Cal's wanted poster on Coruscant#and who might see it
309 notes
·
View notes
Text
Phantom pains
Bonus continuation that didnt fit the comics mood but i dont like leaving characters sad lol:
#great god grove#ggg bizzyboys#ggg ban#ggg alexei#i was talking to someone about tail language in drainfolk#and it was amazing in real time them realizing i was 100% aware of what this meant for Ban in context since his tail is too short#to do most displays instinctual to them#(smiles in being evil from the start like how i originally drew grujaja with his hand over his bizzy pendant)#banalex
243 notes
·
View notes
Text
in honor of Sonic 3 officially releasing I’d like everyone to give a special shoutout to my mom who broke two minor traffic laws to get to the theatre on time. this is what a real autism mom looks like
#sonic#sonic the hedgehog#sonic movie 3#sonic 3#shadow the hedgehog#bc it’s his movie lbr#this is not a joke btw. shes aware and fully expecting to get a citation letter in the mail#for context even before I had my autism diagnosis I have been full blown OBSESSED with the Sonic series since I was 6-7#and as my mom she has gotten the majority of my infodumping/making her watch the shows with me/making her attempt to play the games/etc#she is genuinely as invested in major Sonic related happenings as I am#her favorite characters since I was little have always been Tails and Amy (but like ESPECIALLY Tails)#she does NOT fuck around when it comes to Sonic#autism moms WISH they were her
241 notes
·
View notes
Text
hopping on the trend of drawing miku in my country's traditional clothing, so here; Hatsune Miku in traditional Russian clothing (mainly from the Moscow region)
here's some of the photos i used as like refs for both the pose and the dress design:
#my art#hatsune miku#im aware in the context of giving her two russian braids that means she's married but it would feel weird not drawing her with her pigtails#also thank you to one of my friends who helped with researching some of the moscow region clothing ur a real one fr <3
271 notes
·
View notes
Text
erik will genuinely jump at any chance he can to steal charles' last name and be so catty about it i know this for a fact WHAT is his deal
[Magneto (2011)]
#cherik#snap chats#if i had a nickel every time erik went by 'mr xavier' at some point id have two and its making me wheeze#like at least the first time it was to be headmaster or whatever so it at least makes sense but vjaevlEVEKJV WHY#needed our mandatory charles mention for the magneto issue ig alright ill take it#legit tho why did he feel inclined to steal charles name vjelkvjeaklj like his names 'erik magnus' in this#while i was trying to answer that fashion ask i stumbled upon this thing and gave it a quick read#its only one issue and fairly short so why not#Context Squad I Guess this issue's just sharing the first time erik moves to new york#hence. stealing charles name i guess vjaLVKJAJKL like girl you didnt do anything evil yet ..... alright .... just to be sure ig...#do you ever think he freezes getting called mr xavier or is he so used to it at this point#maybe he twirling his hair and giggling to himself every time he hear it idk#oh but yeah he didnt do anything evil yet. he actually gets his suit in this issue from a woman named cassandra .....#not charles sister of course but still im laughing anyway because he wants her to join him in his Not-Brotherhood group#and shes like 'i met you like five days ago youre insane' and the sort#its an ok read. its unnerving seeing erik smile so much- especially so broadly but its not like. an offensive issue. its standard#it does the job on sharing the story. not that im a critic of any sort vjalkjkaLJ#at the very least it's implied erik has a notable accent in this so thats very cool 🥰#its always cute whenever erik admits hes a drama lover too like vjeLVJEalkvjelkj like at least hes self aware this theater kid 😩#ok bye ive been meaning to work on something but ive been running around all day valkvjkae
200 notes
·
View notes
Text
Hhhh I can't decide how I'm gonna do the relationship reveal in this au...it is going to happen a good while after Jason has come legally back alive and gotten married, but I'm stuck in how it gets revealed and to whom at first. If I'm being nice to Jason and Roy, it would be someone from the Arrows rather than from the Bats, but my need for drama is immense.
#things to know: none of the bats are aware of the beatdown and what happened after it#so they just fully think that jason dipped after he had an argument with bruce and they aren't really looking for him#so it would much more likely be one of the arrows since jason now also lives on the west coast#but again. the drama. the DRAMA#jayroy#context is the secret marriage au
172 notes
·
View notes