[Python] Python - Convert generator object to a dataframe

Discussão em 'Python' iniciado por Stack, Janeiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    **I am using a LLM model through an API and it passes the response. Here i need to read the response(generator obj) variable into a Dataframe as Sno, Name, parent name, Hno, age, enrollment. It works well when i an using print and but it doesn't write the full line When i try to pass response.content to a list then it gives a few characters by characters. Could you suggest how to read the 'response' generator variable to a Dataframe[Sno,Name,Parentname,Hno,age,gender,Enrollment]. **[![enter image description here][1]][1]

    enter code here


    model="meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo",
    messages= msg,
    temperature=0.4,
    top_p=0.7,
    top_k=50,
    repetition_penalty=1,
    stop=["<|eot_id|>","<|eom_id|>"], stream=True)

    ls_text = []
    for chunk in stream:
    ls_text.append(chunk.choices[0].delta.content)
    print(chunk.choices[0].delta.content or "", end="", flush=True)


    [1]: https://i.sstatic.net/1xIuph3L.png

    Continue reading...

Compartilhe esta Página