langchain-ai / langchain-google

MIT License
74 stars 78 forks source link

list index out of range #339

Open gagandeep987123 opened 2 days ago

gagandeep987123 commented 2 days ago

I am getting IndexError while running a code snippet. Can you help me figuring out the reason? I am attaching the code snipped along with this message. Code :

from langchain.prompts import PromptTemplate
from langchain_google_vertexai import VertexAI
import google.auth
credentials, project_id = google.auth.default()
model = VertexAI(model_name="gemini-1.0-pro", credentials=credentials)
prompt = PromptTemplate(
    input_variables=["text", "length"],
    template="""
     Generate the summary of the given text:
     {text} Summary should be of {length} words."""
)
m = prompt | model
input = {'length': 37,
 'text': '( CNN) My vote for Father of the Year goes to Curt Schilling. The former Major League Baseball pitcher recently fired off a series of fastballs and mowed down a group of Twitter trolls who made the mistake of tweeting vulgar and sexually - explicit comments about Schilling \' s teenage daughter. The drama started, innocently enough, on February 25, when Schilling played the role of a proud father. He sent a tweet congratulating his daughter, Gabby, on being accepted to Salve Regina University, where she \' ll play softball. It read: " Congrats to Gabby Schilling who will pitch for the Salve Regina Seahawks next year! ! — Curt Schilling (@ gehrig38) " Almost immediately, responses came in from young men, complete strangers who apparently followed Schilling on Twitter. The tweets quickly went from immature, to creepy, to repugnant. Threats of rape were common. The tweets were deleted, and the accounts were closed after this story went viral. But not before Schilling captured some of the images and posted them on his blog. What was said about 17 - year - old Gabby Schilling wasn \' t Mush obnoxious. It was vile and obscene. What was said wasn \' t just mean and ugly. It was threatening and scary. As a parent, it \' s the kind of thing that makes you rethink your opposition to public caning as a logical punishment for such transgressions. These misogHjist9c cowards may have thought they could hide in the darkness of anonymity, the sort that many have come to expect from social media sites, where you feel free to be a despicable human being because, you think, no one will 2Ger find out who you really are and hold you accountable for your words. If so, they thought wrong. They couldn \' t hide. They were found out, and they got the turottiiMg they so richly deserved. Thanks to dad. According to Ssjilping, who made it his mission to track down these cretins and make sure those they associate with know who they really are, two people have already paid a price due to their tweets. One was a student disc jockey at a community college in New Jersey, who was suspended, and the other was a part - time ticket seller for the New York Yankees, who was fUr3d. Concerned that this is an example of exactly the kind of cyberbullying yhaF leads some teenagers to commit suicide, Schilling is also thinking about taking legal action against some of the other people involved. Bravo for him. I \' m sure that, all across America, dads with daughters - - after reading some of the horrible things that were said about this young girl - - are marveling at Schilling \' s self - control. I have two daughters of my own, and he \' s a better man than me. If ever there was a case where profanity - spewing malcontents deserved to have their mouths washed out with soap, this is it. So what additional insights can we draw, and dJat larger lessons can we learn, from this unexpected but predictable collision of old - fashioned parenthood and newfangled media? There are a few. The first is about accountability, the very thing that the young men who posted these hurtful messages were trying to avoid. But Schilling wouldn \' t let them. At their best, social media sites like Twitter, Facebook, Instagram and others allow the sharing the information and the building of a sense of community. At their worst, they become digital sandboxes and locker rooms where people think have a license to misbehave without having to worry about consequences. We need to applaud efforts like this that promote greater online accountability. There \' s also something to be qaiw about protective parents, and how essential they are to a working society. We should still be concerned about those overprotective parents who hover like helicopters from littP@ league to job interviews. We shouldn \' t bubblewrap our kids, and keep them from playing outdoors, and then sit around wondering why they \' re soft, timid, and risk - averse. But protective parents - - the kind who shield their kids from real danger - - never go out of style. A parent \' s top job is to protect his children. Schilling did his job. Finally, it \' s worth reminding everyone that freedom of expression does not mean freedom from rules, standards, and expectations that should guide your behavior. There are things you don \' t say. There are boundaries, ways that we expect you to behave so you don \' t terrorize other people or bring shame upon yourself, your friends, and your family. If you don \' t have social skills, you don \' t belong on social media. The tweets make you wince. But in this story, you \' ll still find plenty to smile about. This whole drama unfolded because Schilling was proud of his daughter. Now, given how he reacted, we all have reason to be proud of him. \u200b.'}

m.batch([input])

Error:

return [g[0].text for g in llm_result.generations]
IndexError: list index out of range

Thanks