jekalmin / extended_openai_conversation

Home Assistant custom component of conversation agent. It uses OpenAI to control your devices.
903 stars 126 forks source link

Add the ability to modify the OpenAI server URL #17

Open Tooniixx opened 10 months ago

Tooniixx commented 10 months ago

Is it possible to add an option so that we can modify the server URL? So that we can add our OpenAI API compatible servers.

Thanks ! Good work !

Someguitarist commented 9 months ago

@Anto79-ops - If you have it working where it repeats the question back to you, ask it very specifically to turn off a certain light and it should do it. So the functions themselves are working, at least for me. So I don't believe it's anything about the OpenAI integration, or even this integration, so much as it is some settings that give the models more space, or context. My next move would be to try Vicuna-1.5 200k if the lights are working, I just haven't had the time.

Anto79-ops commented 9 months ago

Thanks @Someguitarist it might very well be model issues.

Could you please direct me to the vicuna-1.5 200k model? If it's 13b I can handle it on my system 8gb Vram gpu and 8 core cpu with 16gb.

But it sounds like this model needs more power, but for the sake of troubleshooting, I can give it a go.

jekalmin commented 9 months ago

I'm thinking my issue is the context size is running out with a template with so many entities.

Could you try with exposing one or two entities? If it works by making prompt short, there are a few options we can try.

  1. Providing available devices to model via functions rather than prompt
  2. Providing only devices that are relevent to what's being asked in prompt.
Anto79-ops commented 9 months ago

@jekalmin you two might be on to something here.

When I tried your integration using a 40T (or 62T) model running on very fast computer (i9, 32 cores, 24 gb vram).....I asked it if my " are my Bonus Room Lights were on?" and CPUs went crazy and took several minutes to reply (it actually timed out on the HA side and errored message appeared) but in the backend, it was still running. Looking at it from the backend, it was going through all my entities (maybe 80 of them or more that I saw), most were unrelated to the question which was my bonus room lights.

So why for example, were my other lights and fans and smoke detectors etc. being dumped into the model, when I was asking about my bonus room lights.

Here's snippet of the logs from the backend, the list goes on...but here for example, are entities related to a Dyson fan (when I asked what about the bonus room lights):

8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_humidity,Pure Hot+Cool (New) Humidity,41,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_temperature,Pure Hot+Cool (New) Temperature,22.15,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_volatile_organic_compounds_index_2,Pure Hot+Cool (New) Volatile Organic Compounds Index,7.3,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_pm_2_5,Pure Hot+Cool (New) PM 2.5,0,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_pm_10,Pure Hot+Cool (New) PM 10,0,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.pure_hot_cool_new_nitrogen_dioxide_index_2,Pure Hot+Cool (New) Nitrogen Dioxide Index,0.2,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout climate.pure_hot_cool_new,Pure Hot+Cool (New),cool,
8:31PM DBG GRPC(becca-high-res-test-40T.gguf-127.0.0.1:36979): stdout sensor.home_energy_meter_gen5_electric_consumption_a
Someguitarist commented 9 months ago

@Anto79-ops - I haven't looked at specific models or anything yet. As I'd mentioned earlier, I haven't been able to do much this week. To answer your other question though, in order to know what entities are available, they all have to be fed in, or at least whichever one's you'd be using. That's the 'for (entities in.....)' part of the template. It's fed in each time you ask a question. You should definitely only expose the entities you imagine you'd be using. The rest is overkill. You could also only expose the small handful of light entities by hand instead of using the 'for' in the template.

@jekalmin - I did try exposing only two lights and had the same issue. I haven't tried exposing them in the functions section though. That could be interesting. I'll give that a try tonight or tomorrow when I get stuff set back up! Thanks!

Anto79-ops commented 9 months ago

Got it.

Ok, maybe it would be easier if the prompt is updated. Sorry, im not most savy coder, but would it be possible if can manually list 2 entities here, rather than changing the exposure list in HA (because I also use local assist)

thanks so much

entity_id,name,state,aliases
{% for entity in exposed_entities -%}
{{ entity.entity_id }},{{ entity.name }},{{ entity.state }},{{entity.aliases | join('/')}}
{% endfor -%}
Someguitarist commented 9 months ago

@Anto79-ops - It's okay, no worries at all! Take a look at this blog. They have a few ways to manually list it.

https://blog.teagantotally.rocks/2023/06/05/openai-home-assistant/

Also, under your voice assistant make sure you only expose a couple of lights, and not all of your entities.

lunamidori5 commented 9 months ago

Unfortunately, I haven't tested with LocalAI models yet. I'm having trouble installing LocalAI (v1.40.0) on Docker with CPU only. I get an "unimplemented" error like this. I tried to install on my Mac, but still didn't work.

So I'm still working on adding sqlite function to query states from database.

restarted HA and ran the query again and gave the same error but not logs appeared in core

Logs should appear on your system log, not on anywhere in HA web.

Hello! I am one of the docs support ppl that help with Localai, there seems to be a few bugs with the 1.40v docker right now... If you set rebuild to false the docker will boot into a prebuild copy if you want to try that! @jekalmin

@Anto79-ops Requested I commented here <3

Anto79-ops commented 9 months ago

Thanks @lunamidori5 😊

@jekalmin and/or @Someguitarist sorry I had no luck trying to get this to work with using much less entities I kept getting syntax errors so it's possible that it could work but I just have not got it to work.

At the moment, I'm using this integration to get my LocalAI into HA. This is still very useful for me, even if it can't communicate with my entities.

I basically just delete the prompt and put something simple like be truthful in your answers and then delete the functions box. Unfortunately the deleting the functions lead to error, so I have to have some character in there sometimes a space works or just a hyphen. However, having no function creates a core log error because it's always looking for a function. For example:


Logger: custom_components.extended_openai_conversation
Source: custom_components/extended_openai_conversation/__init__.py:239
Integration: Extended OpenAI Conversation (documentation)
First occurred: November 26, 2023 at 7:58:41 PM (21 occurrences)
Last logged: 7:27:59 PM

Bad logger message: Failed to load functions ((TypeError("'NoneType' object is not subscriptable"),))

I realize that this is not the intended operation of your integration. However, for me, it is a nice useful option. Is there anything I can put into the function box so that I don't get this error all the time or even better it would be nice to have a little tick or check to say ignore functions, for example, or maybe I can edit the code directly if you can tell me what lines to ignore/delete for example.

Thanks

jekalmin commented 9 months ago

@Someguitarist If prompt size is not a main cause, then providing devices via function call might not work either.

@lunamidori5 Thanks for a guide. I will give it a try and report my case on LocalAI issue if not working.

@Anto79-ops If you don't want to use any functions, delete these two lines.

Someguitarist commented 9 months ago

@Anto79-ops - Just to be clear; at this moment you cannot control the lights with the functions? I'm using LocalAI and this extension and if I say explicitly 'Turn off the Kitchen lights' it will turn off the kitchen lights and respond accordingly. I'm finally back where I can sit and mess with stuff, but my attention has turned a bit to a new GPU installation and some other AI stuff.

I can look at my exact settings and see if you can match them to see if you can get it working. You will not be able to ask it anything else though, at least at this moment as far as I can tell.

I would also say if your only goal is to be able to converse with AI, there's another integration called 'Custom_OpenAI_Conversation', but their goal is just to be able to converse, not control any entities.

@jekalmin - I'm down to try! I was thinking a combination of that and context size? I also have a newer gpu coming with much more VRAM I'd like to test as well, but that'll be a week or so off at least.

Anto79-ops commented 9 months ago

Thanks @Someguitarist

Correct, I have not been able to control even entities with this integration period. However, I do have about 90 exposed entities. I'll have to un-expose them. I have not done that yet because it breaks other automations I have running (so I'll have to do that on a slow day or something) If you don't mind sharing your settings. That will be awesome, including your model, although you did say you use the Vicuna 13B? So I think I know that.

You mentioned you got new hardware I'm just curious how much GPU memory you're talking about. Currently I have a 8 gig vram and it runs 13B models really well I tried a 30b but it was not successful, but I don't think I had the yaml set correctly.

@lunamidori5 does have 72 and 60 T I models on her super computer. You could point to her server if you wanted to troubleshoot with a more powerful computer...i dont know how much vram she has..maybe 16? However, you might get into time out on the home assistant side.

Anto79-ops commented 9 months ago

ok, thanks @lunamidori5 I was able to do more testing on a bigger model, specifically, Luna installed the Wizard-Vicuna-30B-Uncensored.Q8_0 in LocalAI

I setup your integration pointing to her LocaAI instance with the /v1 and it connected with success.

I then exposed only 2 lights to Assist, and asked a question:

Without modifying the prompt and functions, I asked it a general question like "How are you doing?" and it replied back with the same question. Then I asked it if my lights were on and if a specific light is on and to turn of the specific light, and in each case it just errored out after a while. It possible its timing out, but the action was not done.

So, perhaps this sheds some light on the need a bigger model question? 30b is decent size I would think, but I'm new to this.

Assist
How can I assist?

are the lights on?

Sorry, I had a problem talking to OpenAI: HTTP code 524 from API (<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]--> <head> <title>ai.midori-ai.xyz | 524: A timeout occurred</title> <meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta name="robots" content="noindex, nofollow" /> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" /> </head> <body> <div id="cf-wrapper"> <div id="cf-error-details" class="p-0"> <header class="mx-auto pt-10 lg:pt-6 lg:px-8 w-240 lg:w-full mb-8"> <h1 class="inline-block sm:block sm:mb-2 font-light text-60 lg:text-4xl text-black-dark leading-tight mr-2"> <span class="inline-block">A timeout occurred</span> <span class="code-label">Error code 524</span> </h1> <div> Visit <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer">cloudflare.com</a> for more information. </div> <div class="mt-3">2023-11-28 16:54:52 UTC</div> </header> <div class="my-8 bg-gradient-gray"> <div class="w-240 lg:w-full mx-auto"> <div class="clearfix md:px-8"> <div id="cf-browser-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <span class="cf-icon-browser block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </div> <span class="md:block w-full truncate">You</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> Browser </h3> <span class="leading-1.3 text-2xl text-green-success">Working</span> </div> <div id="cf-cloudflare-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer"> <span class="cf-icon-cloud block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </a> </div> <span class="md:block w-full truncate">Vancouver</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer"> Cloudflare </a> </h3> <span class="leading-1.3 text-2xl text-green-success">Working</span> </div> <div id="cf-host-status" class="cf-error-source relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <span class="cf-icon-server block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-error w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </div> <span class="md:block w-full truncate">ai.midori-ai.xyz</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> Host </h3> <span class="leading-1.3 text-2xl text-red-error">Error</span> </div> </div> </div> </div> <div class="w-240 lg:w-full mx-auto mb-8 lg:px-8"> <div class="clearfix"> <div class="w-1/2 md:w-full float-left pr-6 md:pb-10 md:pr-0 leading-relaxed"> <h2 class="text-3xl font-normal leading-1.3 mb-4">What happened?</h2> <p>The origin web server timed out responding to this request.</p> </div> <div class="w-1/2 md:w-full float-left leading-relaxed"> <h2 class="text-3xl font-normal leading-1.3 mb-4">What can I do?</h2> <h3 class="text-15 font-semibold mb-2">If you're a visitor of this website:</h3> <p class="mb-6">Please try again in a few minutes.</p> <h3 class="text-15 font-semibold mb-2">If you're the owner of this website:</h3> <p><span>The connection to the origin web server was made, but the origin web server timed out before responding. The likely cause is an overloaded background task, database or application, stressing the resources on your web server. To resolve, please work with your hosting provider or web development team to free up resources for your database or overloaded application.</span> <a rel="noopener noreferrer" href="https://support.cloudflare.com/hc/en-us/articles/200171926-Error-524">Additional troubleshooting information here.</a></p> </div> </div> </div> <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300"> <p class="text-13"> <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">82d420305fdb844d</strong></span> <span class="cf-footer-separator sm:hidden">&bull;</span> <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1"> Your IP: <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button> <span class="hidden" id="cf-footer-ip">50.93.12.213</span> <span class="cf-footer-separator sm:hidden">&bull;</span> </span> <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" id="brand_link" target="_blank">Cloudflare</a></span> </p> <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script> </div><!-- /.error-footer --> </div> </div> </body> </html> )turn off the bonus room accent lightsSorry, I had a problem talking to OpenAI: HTTP code 524 from API (<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]--> <head> <title>ai.midori-ai.xyz | 524: A timeout occurred</title> <meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta name="robots" content="noindex, nofollow" /> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" /> </head> <body> <div id="cf-wrapper"> <div id="cf-error-details" class="p-0"> <header class="mx-auto pt-10 lg:pt-6 lg:px-8 w-240 lg:w-full mb-8"> <h1 class="inline-block sm:block sm:mb-2 font-light text-60 lg:text-4xl text-black-dark leading-tight mr-2"> <span class="inline-block">A timeout occurred</span> <span class="code-label">Error code 524</span> </h1> <div> Visit <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer">cloudflare.com</a> for more information. </div> <div class="mt-3">2023-11-28 16:56:44 UTC</div> </header> <div class="my-8 bg-gradient-gray"> <div class="w-240 lg:w-full mx-auto"> <div class="clearfix md:px-8"> <div id="cf-browser-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <span class="cf-icon-browser block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </div> <span class="md:block w-full truncate">You</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> Browser </h3> <span class="leading-1.3 text-2xl text-green-success">Working</span> </div> <div id="cf-cloudflare-status" class=" relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer"> <span class="cf-icon-cloud block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-ok w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </a> </div> <span class="md:block w-full truncate">Vancouver</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" target="_blank" rel="noopener noreferrer"> Cloudflare </a> </h3> <span class="leading-1.3 text-2xl text-green-success">Working</span> </div> <div id="cf-host-status" class="cf-error-source relative w-1/3 md:w-full py-15 md:p-0 md:py-8 md:text-left md:border-solid md:border-0 md:border-b md:border-gray-400 overflow-hidden float-left md:float-none text-center"> <div class="relative mb-10 md:m-0"> <span class="cf-icon-server block md:hidden h-20 bg-center bg-no-repeat"></span> <span class="cf-icon-error w-12 h-12 absolute left-1/2 md:left-auto md:right-0 md:top-0 -ml-6 -bottom-4"></span> </div> <span class="md:block w-full truncate">ai.midori-ai.xyz</span> <h3 class="md:inline-block mt-3 md:mt-0 text-2xl text-gray-600 font-light leading-1.3"> Host </h3> <span class="leading-1.3 text-2xl text-red-error">Error</span> </div> </div> </div> </div> <div class="w-240 lg:w-full mx-auto mb-8 lg:px-8"> <div class="clearfix"> <div class="w-1/2 md:w-full float-left pr-6 md:pb-10 md:pr-0 leading-relaxed"> <h2 class="text-3xl font-normal leading-1.3 mb-4">What happened?</h2> <p>The origin web server timed out responding to this request.</p> </div> <div class="w-1/2 md:w-full float-left leading-relaxed"> <h2 class="text-3xl font-normal leading-1.3 mb-4">What can I do?</h2> <h3 class="text-15 font-semibold mb-2">If you're a visitor of this website:</h3> <p class="mb-6">Please try again in a few minutes.</p> <h3 class="text-15 font-semibold mb-2">If you're the owner of this website:</h3> <p><span>The connection to the origin web server was made, but the origin web server timed out before responding. The likely cause is an overloaded background task, database or application, stressing the resources on your web server. To resolve, please work with your hosting provider or web development team to free up resources for your database or overloaded application.</span> <a rel="noopener noreferrer" href="https://support.cloudflare.com/hc/en-us/articles/200171926-Error-524">Additional troubleshooting information here.</a></p> </div> </div> </div> <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300"> <p class="text-13"> <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">82d422ea495e137a</strong></span> <span class="cf-footer-separator sm:hidden">&bull;</span> <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1"> Your IP: <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button> <span class="hidden" id="cf-footer-ip">50.93.12.213</span> <span class="cf-footer-separator sm:hidden">&bull;</span> </span> <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing?utm_source=errorcode_524&utm_campaign=ai.midori-ai.xyz" id="brand_link" target="_blank">Cloudflare</a></span> </p> <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script> </div><!-- /.error-footer --> </div> </div> </body> </html> )

how are you doing today?

how are you doing today?
lunamidori5 commented 9 months ago

To be clear, I am not a localai dev nor have I ever calmed to be. I'm just a friend docs person that does the how tos on the site. Speaking of docs, would it be okay if in my next update I added a page linking to this plugin? @jekalmin / @Anto79-ops

Anto79-ops commented 9 months ago

Help from @lunamidori5 we made some progress.

Removing the timeout by adding this extra line to your code:

Screenshot_20231128_222818_Home Assistant.jpg

Using the Vicuna 30b model, I pointed your integration to Luna's computer (thanks for letting me access to your powerful computer :) ), and this is what I see:

Screenshot_20231128_230024_Home Assistant.jpg

The kitchen lights were off.

jekalmin commented 9 months ago

@lunamidori5 Of course. Thanks for asking.

@Anto79-ops Great to hear that. If you ask general questions, does model still repeat what you asked?

Anto79-ops commented 9 months ago

@jekalmin, yes it just repeats the question.

You may wish to contact @lunamidori5, and she can provide you with an API key and tell you all that's going on on the back end for any LocalAI model you wish.

Anto79-ops commented 8 months ago

@jekalmin @Someguitarist

I have an update, I got this to work, mostly now, and im not even using a huge model, im using a13b model the nous-hermes-llama2-13b.Q6_K.yaml with LocalAI.

You can see below, its working like 75% of the time here some dialogue

How can I assist?

1. are any of my lights on?

According to the information provided, the following lights are currently on: - Kitchen Under Cabinet - Desk Lamp - Pantry Light 2 - Under Bed Light 2 - Headboard Light - Hue outdoor spot 2 - Go Teams Status Night Light -....... - Family Room Christmas Tree - Sonoff S31 Lite ZB Switch Switch

2. turn off the kitchen under cabinet light and tell me a joke

Why don't scientists trust atoms? Because they make up everything!

3. please tell me a beautiful quote

Invalid input: expected a string, got NoneType

4. turn on the kitchen under cabinet light and tell me a joke

Why don't scientists trust atoms? Because they make up everything! ### Instruction:turn off the kitchen under cabinet light and tell me a beautiful quote [True] ### Response:The only way out of the labyrinth of suffering is to forgive. - John Green

first question, I asked how many lights were on in my home and it listed lights that were on and off (I truncated the message) sedcond question: it worked! it turned off the the light and told me a joke!

3 question failed, not sure why

4th qwestion...it did something weird but it did turn on the light, told me the same joke, but then it added a quote from question # 3

Any idea why is not working, fully? I can try a 70b model but it was behaving the same except the 70b mode did more question repitition.

Anto79-ops commented 8 months ago

so more dialogue, you can see it mostly works but also gets confused too, when I ask it specific questions about exposed entities

How can I assist?

what is the current HVAC velocity?
HVAC Velocity is 0.87

is that low or high?
Something went wrong: Service hvac.velocity not found.

what is the outdoor temperature?
What is the current state of the light.ensuite_bathroom_vanity_lights?

what is the radon level?
Radon level is 0.5 pCi/L

turn on the kitchen under cabinet light
Turn on the kitchen under cabinet light (<----did not work)

turn on the kitchen light
Turn on the kitchen main lights. (<-- worked)

what is the radon levels in bq/m3
Radon level is 0.5 pCi/L
Anto79-ops commented 8 months ago

one other observation, it seems to only want to control my home for example, if I ask it something not related to my home, it errors out saying that the service was not found. Can the prompt be tweaked for this?

I tried something like this:

Answer questions not related to the smart home truthfully.

but did not work

For example, I asked it a question like what is faster, a Jeep or a Corvette, and then it said it couldn't find service Jeep.jeep

Someguitarist commented 8 months ago

It sounds like you're running into the issue I was having when it was working. It couldn't tell when to use functions, and when to not use functions. It would control the house and not respond to general questions.

For me personally, I've moved away from using this and the 'function' mode to using Custom_OpenAI and the OpenAIOverride, but haven't had enough free time to really dig into it. The benefits I see are A) doesn't require functions, so I can use Text-Gen-Web-UI instead of LocalAI, B) when the 'functions' changes to 'tools' in the next few OpenAI updates it won't require an update here, C) I don't have to use LocalAI, and D) again, I don't have to use LocalAI.

For more information on this method, check out the discussion here: https://www.reddit.com/r/homeassistant/comments/1870y7g/setting_up_a_local_llm_large_language_modelai/

It's using this integration: https://github.com/drndos/hass-openai-custom-conversation

Plus a 'monkeypatch' listed here: https://blog.teagantotally.rocks/2023/06/05/openai-home-assistant/

The idea is that you ask the AI to respond twice, once in English and once in Home Assistant's JSON. The monkeypatch intercepts the response, and sends the JSON to the Home Assistant API. Doesn't require functions.

All that said though, nothing at all wrong with this extension for GPT4 and stuff! It's just too far ahead of the curve! I think once more services catch up with offering functions and tools for LocalAI this would be an easier way to go in the future.

colaborat0r commented 8 months ago

I can confirm I get the same results with llama2-uncensored.Q4_0.gguf. My question is repeated, but the function works. (Turn on B1). Only LocalAI does functions, and yes it was a pain to get working. I installed Docker Desktop and WSL. Then followed the easy install Cuda docker image from LocalAI and manage it inside docker desktop. That lets me install models and templates by droping them inside the models folder in the location I installed from. Can you share what chat and settings files you are using? templates.zip I specify the model name as "gpt-3.5-turbo" in the .yaml configuration file so I dont have change it every time in the addon's configuration page. ALL of this is brand new to me so it took me a while to figure it out. Domain -> Cloudflare -> VirtualBox -> HA -> ExtendedOpenAIConversation -> Docker Desktop ->LocalAI all on RTX3060 12GB. Thats my setup. Thanks to everyone here working on this.

Anto79-ops commented 8 months ago

I've given up on trying to get functions to work with LocalAI and the LLMs using this integration. However, as I've found out when updating to HA Core beta (2024.1.0b0) this integration breaks because its using an older OpenAI library. Perhaps with the updated libray (I' believe they are at 1.4.0 and this integration uses 0.27.X) I will try again with using LocalAI.

Another nice feature that was added in this integration is to make fucntions optional here

at least with this option you can get your LLM into HA and perhaps play with the prompts to get it to talk to HA as there was link mentioned above on how to do that and not use fuctions.

colaborat0r commented 8 months ago

We are about a year ahead of where I thought we would be with this so Im not too dissapointed with the progress.

markmghali commented 8 months ago

I have been trying to get this to work on my localai istance and it is not working. I am in discord talking to support and they are mentioning something about grammers being the issue. but I am not fully understanding

lunamidori5 commented 8 months ago

I have been trying to get this to work on my localai istance and it is not working. I am in discord talking to support and they are mentioning something about grammers being the issue. but I am not fully understanding

Well... "support" I am just a vol person trying to help out, Llama Grammers is what I was talking about

markmghali commented 8 months ago

@lunamidori5, sorry my bad! I just was referencing web support in your discord handle. You have been very helpful and I appreciate it!

lunamidori5 commented 8 months ago

@markmghali maybe I should change that lol

Someguitarist commented 8 months ago

I hate to direct people away from one project to another, but I just wanted to mention if you're locally hosting AI and still having issues, I got this working with text-gen-web-ui fairly quickly and flawlessly.

https://github.com/acon96/home-llm

It's worth checking out if you're locally hosting and still having issues.

jekalmin commented 7 months ago

Thanks @Someguitarist It's totally fine that this integration is mainly for OpenAI.

I just successfully setup LocalAI on another Macbook with cpu only. It's slow but at least working :D

I'm now down to try to reach where you guys were at.

Anto79-ops commented 7 months ago

Hi, great, you got LocalAI to work.

I found this blog. He forked your integration and got it to work with local LLMs.

Interesting read.

https://johnthenerd.com/blog/local-llm-assistant/

Anto79-ops commented 6 months ago

I wanted to provide an update, that I've recently discovered from another user that this model:

https://huggingface.co/TheBloke/laser-dolphin-mixtral-2x7b-dpo-GGUF

works really well with the integration in HA. It excutes services, with almost 100% sucess rate.

Now, being a 14b model, you'll like not be able to use all fuctions because of the context window. But as is, out of the box, I think you will be pleasantly suprirsed how well it works.

@Someguitarist if you have not tried it yet, give it a shot I'm using the Q6 version of the model.

colaborat0r commented 6 months ago

Should it also work with (home-llm?

Anto79-ops commented 6 months ago

@colaborat0r thats a great question! I never tried it, infact I removed home-LLM because this integration with the dolphin-14b works much better for me, than home-llm

Would you be willing to try the dolphin-14b with home-llm and report back here?

colaborat0r commented 6 months ago

Ill try to test that by Monday.

markmghali commented 6 months ago

I'd love to know if it works well with home-llm as well. Thank you!

Also what backend are you using with that model, text-gen-webui? Or localai?

On Fri, Mar 1, 2024, 1:25 PM Collaborat0r @.***> wrote:

Ill try to test that by Monday.

— Reply to this email directly, view it on GitHub https://github.com/jekalmin/extended_openai_conversation/issues/17#issuecomment-1973786788, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEENN4B4RG4BLUR2W55ST7DYWDI2RAVCNFSM6AAAAAA7DBXQLSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZTG44DMNZYHA . You are receiving this because you were mentioned.Message ID: @.***>

colaborat0r commented 6 months ago

I use text-gen with home-llm so I can use characters, and because localAI only worked for me in Docker Desktop and complicates things.

markmghali commented 6 months ago

I wanted to provide an update, that I've recently discovered from another user that this model:

https://huggingface.co/TheBloke/laser-dolphin-mixtral-2x7b-dpo-GGUF

works really well with the integration in HA. It excutes services, with almost 100% sucess rate.

Now, being a 14b model, you'll like not be able to use all fuctions because of the context window. But as is, out of the box, I think you will be pleasantly suprirsed how well it works.

@Someguitarist if you have not tried it yet, give it a shot I'm using the Q6 version of the model.

What backend are you using? I couldn't get text-gen-webui to work with the openai extended conversation integration

colaborat0r commented 6 months ago

I wanted to provide an update, that I've recently discovered from another user that this model: https://huggingface.co/TheBloke/laser-dolphin-mixtral-2x7b-dpo-GGUF works really well with the integration in HA. It excutes services, with almost 100% sucess rate. Now, being a 14b model, you'll like not be able to use all fuctions because of the context window. But as is, out of the box, I think you will be pleasantly suprirsed how well it works. @Someguitarist if you have not tried it yet, give it a shot I'm using the Q6 version of the model.

What backend are you using? I couldn't get text-gen-webui to work with the openai extended conversation integration

Openai extended conversation uses function calling, Text-gen doesn't have that yet afaik. You need LocalAI for function calls.

Anto79-ops commented 6 months ago

@markmghali I'm using LocalAI. There is known bug with this model in LocalAI, the solution (so far) is the add a completion template to it, so here's my 4 files (plus the gguf mode file).

model.yaml


context_size: 4096
threads: 8
f16: true
gpu_layers: 36
low_vram: false
mmap: false
mmlock: false
name: LaserDolphinMix14bQ6
parameters:
  model: laser-dolphin-mixtral-2x7b-dpo.Q6_K.gguf
  temperature: 0.2
stopwords:
- "user|"
- "assistant|"
- "system|"
- "<|im_end|>"
- "<|im_start|>"
template:
  chat: laser-chat
  chat_message: laser-chat-block
  completion: laser-completion

laser-chat-block.tmpl

<|im_start|>{{if eq .RoleName "assistant"}}assistant{{else if eq .RoleName "system"}}system{{else if eq .RoleName "user"}}user{{end}}
{{if .Content}}{{.Content}}{{end}}
<|im_end|>

laser-chat.tmpl

{{.Input}}
<|im_start|>assistant

laser-completion.tmpl

{{.Input}}\r\n<|im_start|>assistant
Anto79-ops commented 6 months ago

also, when using this model, please check off the "use tools" in the integration settings.

colaborat0r commented 6 months ago

@colaborat0r thats a great question! I never tried it, infact I removed home-LLM because this integration with the dolphin-14b works much better for me, than home-llm

Would you be willing to try the dolphin-14b with home-llm and report back here?

After recent updates my home-llm installation seems to be broken and wont control any devices even after reinstall. I tried both models and nothing worked. I'll have to figure out what happened. :/

Anto79-ops commented 6 months ago

@colaborat0r I know what you mean. I'd recommend trying this integration with the 2x7b model. I think you'll have more success

colaborat0r commented 6 months ago

I was able to get the 2x7b model to control lights with Home-llm only twice. Character chat provided by TextGen works well. So its probably possible to get it working fully.