avatarHailey

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2796

Abstract

quote><p id="3487">Run the following script with <code>root </code>priviledges:</p><div id="ca20"><pre>curl -fsSL https://ollama.com/install.sh | sh</pre></div><p id="5309">Once ollama is setup, open your terminal (in both <i>Windows </i>or <i>Linux</i>) and type the following command:</p><div id="9f60"><pre>ollama pull llama3</pre></div><figure id="5b90"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*_W7f8UlwxvS_rUo-0TR0rA.png"><figcaption>This pulling of the files will take some time (for me it took approx 5min)</figcaption></figure><p id="b703">Open your preffered python editor and create a folder with the name <code><i>local_llm</i></code><i>.</i></p><p id="f823">Inside this folder create a <code><b>requirements.txt</b></code><b> </b>file and paste the follwoing content.</p><div id="d102"><pre><span class="hljs-attr">ollama</span>==<span class="hljs-number">0.1</span>.<span class="hljs-number">8</span> <span class="hljs-attr">streamlit</span>==<span class="hljs-number">1.33</span>.<span class="hljs-number">0</span></pre></div><p id="ce14">Now, let’s create a file named <code>app.py</code> and add the following code:</p><div id="5ef4"><pre><span class="hljs-keyword">import</span> streamlit <span class="hljs-keyword">as</span> st <span class="hljs-keyword">import</span> ollama</pre></div><p id="3942">Next, we’ll create the Streamlit app. We’ll start by setting the title and initializing the message history:</p><div id="3676"><pre>st.title(<span class="hljs-string">"💬 Local LLMBot"</span>)

<span class="hljs-keyword">if</span> <span class="hljs-string">"messages"</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> st.session_state: st.session_state[<span class="hljs-string">"messages"</span>] = [{<span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, <span class="hljs-string">"content"</span>: <span class="hljs-string">"How can I help you?"</span>}]</pre></div><p id="a189">Now, let’s display the chat history by iterating through the messages:</p><div id="5df4"><pre><span class="hljs-keyword">for</span> msg <span class="hljs-keyword">in</span> st.session_state.messages: <span class="hljs-keyword">if</span> msg[<span class="hljs-string">"role"</span>] == <span class="hljs-string">"user"</span>: st.chat_message(msg[<span class="hljs-string">"role"</span>], avatar=<span class="hljs-string">"🧑‍💻"</span>).write(msg[<span class="hljs-string">"content"</span>]) <span class="hljs-keyword">else</span>: st.chat_message(msg[<span class="hljs-string">"role"</span>], avatar=<span class="hljs-string">"🤖"</span>).write(msg[<span class="hljs-string">"content"</span>])</pre></div><p id="c986"><b><i>Creating the Response Generator</i></b></p><p id="f311"

Options

To generate responses using Ollama, we’ll create a function called <code>generate_response()</code>. This function will use the <code>ollama.chat()</code> function to generate responses in a streaming manner:</p><div id="41f7"><pre><span class="hljs-keyword">def</span> <span class="hljs-title function_">generate_response</span>(): response = ollama.chat(model=<span class="hljs-string">'llama3'</span>, stream=<span class="hljs-literal">True</span>, messages=st.session_state.messages) <span class="hljs-keyword">for</span> partial_resp <span class="hljs-keyword">in</span> response: token = partial_resp[<span class="hljs-string">"message"</span>][<span class="hljs-string">"content"</span>] st.session_state[<span class="hljs-string">"full_message"</span>] += token <span class="hljs-keyword">yield</span> token</pre></div><p id="4d2e"><b><i>Adding User Input and Generating Response</i></b><i>s</i></p><p id="2a90">Lastly, we’ll add a chat input field using Streamlit and create a function to handle the user’s input. When the user enters a message, we’ll append it to the messages list and display it in the chat window. We’ll then clear the <code>full_message</code> state variable and start streaming the response:</p><div id="d199"><pre><span class="hljs-keyword">if</span> prompt := st.chat_input(): st.session_state.messages.append({<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: prompt}) st.chat_message(<span class="hljs-string">"user"</span>, avatar=<span class="hljs-string">"🧑‍💻"</span>).write(prompt) st.session_state[<span class="hljs-string">"full_message"</span>] = <span class="hljs-string">""</span> st.chat_message(<span class="hljs-string">"assistant"</span>, avatar=<span class="hljs-string">"🤖"</span>).write_stream(generate_response) st.session_state.messages.append({<span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, <span class="hljs-string">"content"</span>: st.session_state[<span class="hljs-string">"full_message"</span>]})</pre></div><p id="a4eb"><b><i>Running the App</i></b></p><p id="6673">To run the app, simply execute the following command in your terminal:</p><div id="4de5"><pre>streamlit run app.py</pre></div><h2 id="4e58">Conclusion</h2><p id="b825">In this article, we’ve learned how to create a local chatbot using <i>Ollama </i>and <i>Streamlit</i>. By combining these powerful tools, you can build your own chatbot with a user-friendly interface, making it easy to interact with the ‘<i>llama3</i>’ model. This is just the beginning, and you can further customize and expand the functionality of your chatbot by integrating additional features and models.</p></article></body>

4 Top Celebrities With FBI Investigations You Didn’t Know

The dark side — shocking stars with the secret FBI records.

Source: Image by author

Celebrity life is often hidden behind glamor and glitz, but some have had their reputations dented by the disclosing of their FBI files.

These records include data gathered by the Federal Bureau of Investigation on people assumed to pose a threat to the nation’s interests or be involved in criminal activity.

While some famous people have been linked to serious crimes, others have only attracted attention due to their political opinions or associations with questionable groups.

The disclosure of these files can provide insight into the private lives of these well-known celebrities, and it quite often sparks debate about privacy, surveillance, and how to find the right balance between civil liberties and national security.

1. Tupac Shakur

Image Source: Unsplash

One of the most famous and contentious rappers of all time, Tupac Shakur was renowned for his influential and compelling lyrics that addressed issues like poverty, police violence, and racism.

Tupac’s death is a tragic one — he was shot and killed in Las Vegas in1996.

The FBI made public their files on the rap artist in the years after — Tupac’s passing. These documents provided insight into how the organization had monitored the rapper while he was alive.

The file showed that Tupac had been under FBI surveillance since at least 1991, when he was only 20 years old, and the data that the FBI gathered on him was mind bogglingly.

Tupac’s travels, financial dealings, and alleged involvement in criminal activities were all documented in FBI files, as were conversations with friends and colleagues, associates, and family members.

The release of these FBI documents generated debate and raised questions about the legality and morality of the government’s surveillance of activists and celebrities.

2. Michael Jackson

Image Source: Wikimedia Commons

As one of the most famous musicians and dancers of all time, Michael Jackson’s FBI files certainly caused a great deal of interest and controversy.

The documents, which the FBI had gathered over a number of decades, were first made public in 2009, shortly after Jackson passed away. They released documents totalled over 600 pages.

How frequently Jackson had been the target of extortion attempts during his career was among the most important findings in the FBI files.

The records describe a number of incidents in which someone threatened to reveal negative information about Jackson unless he gave them money, including one incident in which a person claimed to have nude images of the singer.

The documents contain details about the FBI’s investigation into Jackson’s possible involvement in child molestation in the early 1990s.

The investigation began after the father of a 13-year-old kid accused Jackson of molesting his son sexually. In the end, Jackson was cleared of all accusations following a criminal trial in 2005.

3. John Lennon

Image Source: Wikimedia Commons

The Federal Bureau of Investigation (FBI) had been keeping an eye on John Lennon for almost a decade. Lennon was one of the most popular and influential musicians of the twentieth century.

The American government became aware of Lennon because of his activism against the Vietnam War and his connections with Marxist organizations, which led them to perceive him as a possible threat to national security.

As Lennon and his wife Yoko Ono became outspoken anti-war activists and began planning rallies and demonstrations across the nation in 1971, the FBI started looking into lennon.

The FBI viewed Lennon as a subversive and a danger to national security.

The FBI’s files on Lennon were vast and included information on his political activities, his personal life, and even his drug use.

The documents included information about Lennon’s travels, his connections to political activists and parties, and his financial status. Lennon’s correspondence with other activists, including his phone conversations, and meetings, were all under FBI surveillance.

Lennon was still being observed by the FBI after arriving in the country permanently in 1971. Because of his political engagement, the agency attempted to deport him on the grounds that he posed a threat to national security.

Lennon fought back, and with the aid of advocates and attorneys, he was successful in staying in the country.

The extent of government surveillance and the lengths they would go to in order to silence critics were made clear in 1983 when Lennon’s FBI files were made public.

Although the documents were substantially redacted, they gave insight into how the government surveilled a well-known artist and activist.

4. Muhammad Ali

Image Source: Wikimedia Commons

Muhammad Ali was an American professional boxer who was famous for his charisma, popularity, boxing prowess, and public persona.

Ali was a controversial figure in the 1960s and 70s, especially because of his unwavering stance on the Vietnam War and his opinion on racial and religious issues.

Ali was investigated by the Federal Bureau of Investigation because of his political activism , and as far as his FBI files are concerned they have been a popular topic for many years.

By looking at the FBI files on Ali, it is easy to see how the FBI monitored Muhammad Ali from the 1960s till the 1980s.

The files revealed that the FBI monitored every move, every interaction he had, and his meetings with two other activists Martin Luther King Jr and Malcolm X.

One of the most controversial aspects of the FBI’s surveillance of Ali was their attempts to defame him and spoil his public image.

The FBI launched a disinformation campaign against Ali, by spreading false information about his supposed links to the Black Panthers and other criminal organizations.

However, one thing which is clear as day is that Ali resisted FBI’s pressure to cooperate with them and work with them as an informant.

Final Words

Image Source: Wikimedia Commons

The FBI’s interest in keeping a close eye on famous people for potential threats is demonstrated by the fact that there are records on some most famous celebrities.

Investigative motives might range from illegal activities to political activism. The FBI’s interest in high-profile individuals is not surprising given their power and impact on society.

More from the author:

History
Education
Entertainment
Culture
Life
Recommended from ReadMedium