You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

DictionaryExtensions.cs 829 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace LLama.Extensions
  5. {
  6. public static class DictionaryExtension
  7. {
  8. public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> pair, out T1 first, out T2 second)
  9. {
  10. first = pair.Key;
  11. second = pair.Value;
  12. }
  13. public static void Update<T1, T2>(this Dictionary<T1, T2> dic, IDictionary<T1, T2> other)
  14. {
  15. foreach (var (key, value) in other)
  16. {
  17. dic[key] = value;
  18. }
  19. }
  20. public static T2 GetOrDefault<T1, T2>(this Dictionary<T1, T2> dic, T1 key, T2 defaultValue)
  21. {
  22. if (dic.ContainsKey(key))
  23. {
  24. return dic[key];
  25. }
  26. return defaultValue;
  27. }
  28. }
  29. }

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。